[derby] problem with creating a table

Hi! I've a problem with my code.

package jdbc;

import java.sql.*;

publicclass Main{

publicstaticvoid main(String[] args)throws ClassNotFoundException, SQLException{

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

String url ="jdbc:derby:MYDB";

Connection conn = DriverManager.getConnection(url,"nbuser","nbuser");

String s ="CREATE TABLE coffees " +

"(cof_id INT (4) NOT NULL ," +

"cof_name VARCHAR (20) NOT NULL);";

Statement create = conn.createStatement();

ResultSet result = create.executeQuery(s);

}

}

which throws me an sql syntax error (bracket before '4'). But according to http://db.apache.org/derby/manuals/reference/sqlj27.html#CREATE+TABLE+statement query syntax should be ok. DB is created properly. So what is the problem. Please, give me some tip. Greetings.

[1440 byte] By [bobens_83a] at [2007-11-26 22:18:22]
# 1
I don't see anything in that document suggesting that you're correct in thinking that it's ok to specify a datatype size as part of an integer datatype declaration. So presumably you can't.
dcmintera at 2007-7-10 11:13:07 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

My fault. I was insinuated because creating new INT field in netBeans you can specify it's size like here in the tutorial http://java.sun.com/docs/books/tutorial/jdbc/basics/tables.html

Maybe You would be able to explain me some thing, that is:

When I create MYDB database from code using String url = "jdbc:derby:MYDB; create=true";

and then I create a table coffees as shown in the post above (after correcting my mistake it's ok I can insert, select etc). When I add that MYDB to the netBeans (Runtime > Databases > New connection) with settings:

Name: Java DB Embedded

Database URL : jdbc:derby:C:\netBeansProjects\jdbcManually\MYDB

user, password: nbuser

when I connect to that db from netBeans - I can't see coffees table

bobens_83a at 2007-7-10 11:13:07 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

I don't know anything about NetBeans. If you can't reproduce the problem outside the NetBeans environment, therefore, it's not my problem. My best guess would be that the directory you provided in the connection string does not correlate with the working directory extant when you created the database. Look and see where the database files got created.

dcmintera at 2007-7-10 11:13:07 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...