aspose file tools*
The moose likes JDBC and the fly likes excel, sql, and  java  NO DATA FOUND Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "excel, sql, and  java  NO DATA FOUND" Watch "excel, sql, and  java  NO DATA FOUND" New topic
Author

excel, sql, and java NO DATA FOUND

jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
while (rs.next()) {
BPO = new BasisPlusObjects();
BPO.setProjectTitle(rs.getString("ProjectTitle"));
BPO.setProjectNumber(rs.getString("ProjectNumber"));
BPO.setGeoArea(rs.getString("Geo Area"));

task = rs.getString("Task1");
if( task != null) {
BPO.setTasks(task);

BPOObjectArray[i++] = BPO;

In the code above rs.getString("Task1"); will alway return null. Strange cause it should return a string. All the other getString() methods work fine.

Do you think it is a problem with sun.jdbc.odbc.JdbcOdbcDriver.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Jite,
Welcome to JavaRanch!

Can you show the SQL query used? Does it work if you call rs.getString(4) [or whatever the index is] ?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
Thanks i feel welcome already !

No, i tried using the index too, but i got the same "null".

Here's the SQl query

try{
Class.forName(driver);
connection = DriverManager.getConnection("jdbcdbc:usgs_proj_v4", "", "");
st = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = st.executeQuery( "Select * from [Sheet1$]" );
}
catch(Exception ex){ex.printStackTrace();}
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
>In the code above rs.getString("Task1"); will alway return null.
>Do you think it is a problem with sun.jdbc.odbc.JdbcOdbcDriver
What's your sql? From your code, I can't see issue. You can download an evaluation HXTT Excel driver from http://www.hxtt.com/excel.html , and repeat your test. If it works normal, then you have to change column list in your sql or check whether your data in sheet triggers the known data type scan bug of ODBC Excel driver.
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
>rs = st.executeQuery( "Select * from [Sheet1$]" );
For instance, try
rs = st.executeQuery( "Select ProjectTitle,ProjectNumber,[Geo Area],Task1 from [Sheet1$]" );
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
Wei Dai,

i tried what you suggested
rs = st.executeQuery( "Select ProjectTitle,ProjectNumber,[Geo Area],Task1 from [Sheet1$]" );

but rs.getString("Task1"); still returns a null.

i'm downloading the HXTT Excel driver right now.
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
I hope y'all be here tomorrow cause the help desk isn't installing my driver till tomorrow (if i'm lucky).

Funny, i think i'm the only developer that doesn't have administrative rights to his own machine. (i can't even change a path if i wanted too)

LOL.
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
So, i found out that the problem is with microsoft excel and not my code.

To cut a long story short, excel gets very confused when its fields contain both strings and numbers.

There are two soultions to the problem, but neither is practical. (retyping the whole sheet ! for example)

There's more at microsoft.com (not hard to find)
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Thanks for sharing that!
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
>>or check whether your data in sheet triggers the known data type scan bug of ODBC Excel driver.
>To cut a long story short, excel gets very confused when its fields contain both strings and numbers.
Yeah. That's the key
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: excel, sql, and java NO DATA FOUND