View Poll Results: poll me
- Voters
- 1. You may not vote on this poll
Multiple Choice Poll.
Results 1 to 5 of 5
- 12-09-2010, 01:59 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
Read (using Odbc)and write using (POI api)
Hi ALL,
I tried to to read and write the data through excel files.But i am facing some issues while reading and writting the data.The exceptions which are coming are mentioned below
__________________________________________________ _________________________________
Exception:
sqlselect 'villno','fno','w_name', 'age','idno','adcode','caste','educ','height' from [studyhb$]
java.sql.SQLException: Column not found
at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(Unknown Source)roundSQL
select `month1`,`year1`,`round1`, `ttab1`,`teat1`,`m_wt1`,`m_pre1`, `eff11`,`eff12`,`eff13`,`hedu1`,`other1` from [studyhb$] where villno='' and fno='' and w_name='' and idno=''
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at db.ReadOdbc.WriteFirstRowOfInputSheet(ReadOdbc.jav a:283)
at db.ReadOdbc.main(ReadOdbc.java:66)
java.sql.SQLException: Column not found
at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at db.ReadOdbc.GetSQLString(ReadOdbc.java:240)
at db.ReadOdbc.WriteFirstRowOfInputSheet(ReadOdbc.jav a:300)
at db.ReadOdbc.main(ReadOdbc.java:66)
java.sql.SQLException: [Microsoft][ODBC Excel Driver] Data type mismatch in criteria expression.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unkno wn Source)
at db.ReadOdbc.WriteFirstRowOfInputSheet(ReadOdbc.jav a:305)
at db.ReadOdbc.main(ReadOdbc.java:66)
java.lang.NullPointerException
__________________________________________________ _______________________________
I want that the data i am reading should be wriiten in excellsheet(output).The write file is now writting only headers.
Please guide me how to do this
- 12-09-2010, 02:24 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
That means that one of theseJava Code:java.sql.SQLException: [Microsoft][ODBC Excel Driver] Data type mismatch in criteria expression.
is probably a number field and not a text field (and they would have to be a text field in order to match a text criteria of ''.Java Code:where villno='' and fno='' and w_name='' and idno=''
- 12-10-2010, 07:40 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
Hi masijade,
all fields are define as a string but still i m facing same issue
- 12-10-2010, 09:34 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
My solution would be...don't treat Excel as a database.
It isn't.
- 12-10-2010, 11:00 AM #5
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Do they actually contain strings, or do they contain numbers. If they contain numbers then the ODBC driver will treat them number fields even if you used the cell formatting to tell excel to display numbers as strings. And, if a column contains both numbers in some cells and strings in other cells, then the ODBC driver will determine the type based on which is more populous. IOW, as mentioned before, do not treat excel as a DB, unless you are aware of the problems and know that that sheet won't trigger any of them (and there are a lot of possible triggers).
Similar Threads
-
XML read/write in Java
By bogdy.laurentiu in forum XMLReplies: 5Last Post: 05-31-2010, 06:08 PM -
Read/Write Files
By FlyNn in forum New To JavaReplies: 3Last Post: 02-06-2010, 08:45 PM -
How to read/write txt in Java
By megalomitis in forum New To JavaReplies: 2Last Post: 11-13-2009, 10:09 AM -
How to read first 9 bytes and write in...?
By aRTx in forum New To JavaReplies: 8Last Post: 03-26-2009, 02:54 PM -
Read and Write file
By mrdestroy in forum New To JavaReplies: 13Last Post: 10-31-2008, 12:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks