Derby 10.5 + JDK1.6

View: New views
4 Messages — Rating Filter:   Alert me  

Derby 10.5 + JDK1.6

by shaf :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Please be patient as I am new to using Derby. I am using the embedded
jdbc driver in my application and it seems that I am able to insert a
row using java without any exceptions but when I browse using the table,
I dont see the new row that I originally inserted. A snipped of my code
looks as follows:

           Class.forName( DERBY_DRIVER ).newInstance();
           //Get a connection
           Connection conn = DriverManager.getConnection(
"jdbc:derby:directory:/home/shaffin/testdb;create=true", "admin",
"password" );
           conn.setAutoCommit(true);
                     PreparedStatement stmt =
conn.prepareStatement("insert into tbltest (fld1, fld2) values(?,?)");
           stmt.setString(1, "fld1test");
           stmt.setString(2, "fld2test");

           c = stmt.executeUpdate();

           stmt.close();
           conn.close();

Any help is kindly appreciated.

Shaffin.


Re: Derby 10.5 + JDK1.6

by Sylvain Leroux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Shaffin

And welcome to Derby ;)

> when I browse using the table, I dont see the new row that I originally inserted
What kind of tool are you using to "browse" the table? ij? Or is it from a
custom written program? My first guess would be that there was a problem while
reading back the data.

 >           c = stmt.executeUpdate();
However, just to be sure, it could be interesting to check the return value of
executeUpadte, in order to see if a row was really inserted by your statement.

Not sure this is relevant, but what's your platform?

Sylvain


Shaffin Bhanji a écrit :

>
> Hello,
>
> Please be patient as I am new to using Derby. I am using the embedded
> jdbc driver in my application and it seems that I am able to insert a
> row using java without any exceptions but when I browse using the table,
> I dont see the new row that I originally inserted. A snipped of my code
> looks as follows:
>
>           Class.forName( DERBY_DRIVER ).newInstance();
>           //Get a connection
>           Connection conn = DriverManager.getConnection(
> "jdbc:derby:directory:/home/shaffin/testdb;create=true", "admin",
> "password" );
>           conn.setAutoCommit(true);
>                     PreparedStatement stmt =
> conn.prepareStatement("insert into tbltest (fld1, fld2) values(?,?)");
>           stmt.setString(1, "fld1test");
>           stmt.setString(2, "fld2test");
>
>           c = stmt.executeUpdate();
>
>           stmt.close();
>           conn.close();
>
> Any help is kindly appreciated.
>
> Shaffin.
>
>
>


--
Website: http://www.chicoree.fr



Re: Derby 10.5 + JDK1.6

by Sylvain Leroux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Second guess:

Since you are connected as "admin" at insert time, your row is inserted into
ADMIN.TBLTEST.

On the other hand, if you are connected anonymously to the DB while reading,
chances are you're are using instead APP.TBLTEST at that time.

Of course, this only could happen without error if you have created both
ADMIN.TBLTEST and APP.TBLTEST at some point during your tests. OK, I know that's
a lot of "if"...

Sylvain

Shaffin Bhanji a écrit :

>
> Hello,
>
> Please be patient as I am new to using Derby. I am using the embedded
> jdbc driver in my application and it seems that I am able to insert a
> row using java without any exceptions but when I browse using the table,
> I dont see the new row that I originally inserted. A snipped of my code
> looks as follows:
>
>           Class.forName( DERBY_DRIVER ).newInstance();
>           //Get a connection
>           Connection conn = DriverManager.getConnection(
> "jdbc:derby:directory:/home/shaffin/testdb;create=true", "admin",
> "password" );
>           conn.setAutoCommit(true);
>                     PreparedStatement stmt =
> conn.prepareStatement("insert into tbltest (fld1, fld2) values(?,?)");
>           stmt.setString(1, "fld1test");
>           stmt.setString(2, "fld2test");
>
>           c = stmt.executeUpdate();
>
>           stmt.close();
>           conn.close();
>
> Any help is kindly appreciated.
>
> Shaffin.
>
>
>


--
Website: http://www.chicoree.fr



Re: Derby 10.5 + JDK1.6

by shaf :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you Sylvain,

It seems that Eclipse's Database Development plugin does not read back
the table for some reason when using the "Generic JDBC" hook that it
comes with. When I selected the "Derby JDBC 10.2" hook with the 10.5  
derby.jar works like a charm.

Shaffin.


Sylvain Leroux wrote:

> Second guess:
>
> Since you are connected as "admin" at insert time, your row is
> inserted into ADMIN.TBLTEST.
>
> On the other hand, if you are connected anonymously to the DB while
> reading, chances are you're are using instead APP.TBLTEST at that time.
>
> Of course, this only could happen without error if you have created
> both ADMIN.TBLTEST and APP.TBLTEST at some point during your tests.
> OK, I know that's a lot of "if"...
>
> Sylvain
>
> Shaffin Bhanji a écrit :
>>
>> Hello,
>>
>> Please be patient as I am new to using Derby. I am using the embedded
>> jdbc driver in my application and it seems that I am able to insert a
>> row using java without any exceptions but when I browse using the
>> table, I dont see the new row that I originally inserted. A snipped
>> of my code looks as follows:
>>
>>           Class.forName( DERBY_DRIVER ).newInstance();
>>           //Get a connection
>>           Connection conn = DriverManager.getConnection(
>> "jdbc:derby:directory:/home/shaffin/testdb;create=true", "admin",
>> "password" );
>>           conn.setAutoCommit(true);
>>                     PreparedStatement stmt =
>> conn.prepareStatement("insert into tbltest (fld1, fld2) values(?,?)");
>>           stmt.setString(1, "fld1test");
>>           stmt.setString(2, "fld2test");
>>
>>           c = stmt.executeUpdate();
>>
>>           stmt.close();
>>           conn.close();
>>
>> Any help is kindly appreciated.
>>
>> Shaffin.
>>
>>
>>
>
>