steve lescure <[email protected]> writes:
> thanks that was a great big help! never would have figured all that
> out.
>
> i can now connect to the database............now i've encounter yet
> another mystery.
>
> It keeps telling me it can't find my table JOBS....i've read that
> NETBEANS should create a default schema NBUSER (the id I used to when
> i created the db). When i check the properties of the database, the
> schema is indeed NBUSER. however, to create a table i have to use the
> APP schema (NBUSER is not in the list). I did that, but NETBEANS can't
> find the table even if i use APP.JOBS... I've tried JOBS APP.JOBS
> NBUSER.JOBS all fail.
>
> any thoughts?
>
>
> try {
> Properties props = new Properties(); // connection properties
> props.put("user", "nbuser");
> props.put("password", "nbuser");
> String dbName = "DEMAND"; // the name of the database
>
> conn = DriverManager.getConnection(protocol + dbName
> + ";create=false", props);
> System.out.println("Connected to database " + dbName);
>
> conn.setAutoCommit(true);
> s = conn.createStatement();
> statements.add(s);
> rs = s.executeQuery(
> "SELECT JOBNAME, USERID FROM APP.JOBS");
> (dies here)
Did you set derby.system.home to ~/.netbeans-derby for your application.
If you didn't, the code above will connect to a database in the current
working directory (if there is one with that name) instead of the
database in ~/.netbeans-derby.
Alternatively, you can specify the full path to the database in the
connection URL:
jdbc:derby:/home/steve/.netbeans-derby/DEMAND
If you've already done this and it doesn't work, you could make your
application print all your tables and which schema they're in by
changing your query to:
rs = s.executeQuery(
"select schemaname || '.' || tablename from " +
"sys.systables t, sys.sysschemas s " +
"where t.schemaid=s.schemaid and schemaname not like 'SYS%'");
System.out.println("Tables:");
while (rs.next()) {
System.out.println(rs.getString(1));
}
--
Knut Anders