-
Derby Mystery..!!!!
Hi
Could anyone please advice me about a strange behavior of derby Database?
1. I have created a table in an Embedded Derby Database with the name "PC"
2. In this table there is a field with the name "EMPID" type of INT, and it is accepting null entries.
3. I have created the dbconnection
dBconnection = DriverManager.getConnection(connString + database,
user, password);
4. I have created a Result Set and a Prepared Statement as well:
private PreparedStatement readXrPc;
private ResultSet resultSet;
5. Then I created the initialize prepare statement:
readXrPc = dBconnection.prepareStatement("SELECT * FROM
APP.PC WHERE EMPID=?");
6. Then I created a method in order to read the records I want..
public ArrayList<PcClass> readEmpIdPc(int ypid){
try{
readXrPc.setInt(1, ypid);
resultSet = readXrPc.executeQuery();......
7. I called the method with ypid=25 (I have at least two entries with this ID in my table)..
Nothing happens.. the result set is empty..
When i run the same SQL qyery in the SQL editor everything is Ok and i have the correct results..
I changed the select statement to "SELECT * FROM APP.PC" and I override the method "toString" in roder to see what entries we have in the result set for the field EMPID..
I saw that when this field has one entry (everything not only the 25 i am looking for) the result is the number 1..
And when there is no entry (null) the result is 0...
Could anyone knows what is going wrong here..?
:(:(:(
-
just a newbie also...
but in my case...i have to connect using Netbeans..in SERVICES tab.
when connected..it will display as follows:
2011-01-22 21:37:05.044 GMT : Security manager installed using the Basic server security policy.
2011-01-22 21:37:10.046 GMT : Apache Derby Network Server - 10.5.3.0 - (802917) started and ready to accept connections on port 1527
-
Well, in your create table statement, did you designate the column as "NOT NULL"?
-
Can you show us the code where to loop through the resultset?