db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Embretsen <John.Embret...@Sun.COM>
Subject Re: Newbie Blues : Unable to connect to derby database using JDBC
Date Fri, 16 Nov 2007 10:18:42 GMT

I see that your class is based on Derby's simple demo. Once you start modifying 
the database or parts of the demo code, care should be taken to ensure that the 
rest of the code is still valid. For example, the data verification part is very 
specific to the data inserted by the demo.

If you need more info on how to work with JDBC (for example ResultSets), I 
recommend this tutorial:



Jørgen Løland wrote:
> Hi Aneez
> The codeline that causes you trouble is this:
> line 66: if (rs.getInt(1) != 300)
> Looking at your select query, what you try to do here is to get an 
> integer from the "firstname" column (firstname is column number 1).
> If you are trying to get the integer stored in the uid column, you need 
> to add it to the select query like this:
> select uid, firstname, lastname from users where uid=1001
> If this is what you want, rs.getInt(1) will never be 300, though. The 
> query specifies that only the row with uid 1001 will be returned.
> Aneez Backer wrote:
>> Hi
>> I have attached the Java source file. The error is as follows when I 
>> run the program:
>> ------------------------------
>> SimpleApp starting in embedded mode.
>> Loaded the appropriate driver.
>> Connected to 24k
>> exception thrown:
>> java.sql.SQLDataException: Invalid character string format for type int.

View raw message