db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Crowell <JimCrow...@EMail.com>
Subject Re: Java stand alone application question?
Date Tue, 02 Jun 2009 12:32:41 GMT

Kristian,
>   Hi Jim,

>   I admit I haven't looked in detail at your complete mail (it's getting 
>   late here at JavaOne...), but I do see a few issues.

>   If you connect to Derby without specifying a user name, it will use APP 
>   by default. APP will also be the selected schema. This means that your 
>   ij query is trying to find the table APP.AB.
>   To fix this, you can either connect with the user ME (with default 
>   settings you don't have to actually create the user, nor set the 
>   password), you can connect with any user you want and then run "SET 
>   SCHEMA ME", or specify the table with the schema name (ME.AB).
That did it.
I added the "SET SCHEMA ME;" command to my script file and eliminated the
test SQL statements and it all runs well.
Many Thanks...

>   When it comes to ij, you can play around with just executing normal 
>   statements before trying to get the prepared statements working. For 
>   ad-hoc activities, I find prepared statements a bit awkward to work with 
>   in ij.
>   For instance, just type in the SQL (assuming the schema is set to ME);
>   INSERT INTO AB VALUES ('abc', 'def'), ('aaa', 'bbb');
>   SELECT * FROM AB;
I was doing interactive ij but went to the script file only to save some
typing. I added the Insert SQL so that I could cut and paste the 'ij'
processing
in the current thread.

>   For the Java JDBC insert code, I would suggest going back to using a 
>   prepared statement, something like this:
>   PreparedStatement psInsert = conn.prepareStatement(
>       "INSERT INTO AB VALUES (?,?)");
>        for (int i...) {
>           psInsert.setString(1, keyName);
>           psInsert.setString(2, segments[i]);
>           psInsert.executeUpdate();
>        }
>        psInsert.close();
>   // If autocommit is disabled, commit the transaction.
>   conn.commit();
I originally had very similar code and committed  it out to try
the Non PreparedStatement approach during my debug efforts.

I just un- committed the code and it works fine.

I was not going to use 'ij' at all but went to it to verify my insert Java
method.
Ideally I want to have some utility methods that I can invoke during debug
to display the Derby  Data Base Tables content.

Now that I know the table is being generated properly I'll continue to
debug my Derby  Data Base display method.

>   Hope this helps,
>   Kristian



-----
Regards,
Jim...
-- 
View this message in context: http://www.nabble.com/Java-stand-alone-application-question--tp23822083p23831661.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.


Mime
View raw message