Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading excel file with data in chinese language using jdbc

 
Neil Jen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

i am having one problem. I have an excel sheet with data in chinese, i am trying to fetch data from this file using jdbc but i am getting the error message as "[Microsoft][ODBC Excel Driver]COUNT field incorrect"

here is my query : select distinct 地区 from [data1$]
 
Ranga Medagoda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you could provide some more info, such as a code snippet. It could be more easier to answer. Hope you are using the correct driver.
 
Neil Jen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranga Medagoda wrote:If you could provide some more info, such as a code snippet. It could be more easier to answer. Hope you are using the correct driver.


here is the code snippet i am trying to execute:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbcdbcriver={Driver do Microsoft Excel(*.xls)};DriverID=22;READONLY=false;DBQ=D:\\temp\\DataSource\\chinese.xls", "", "");

Statement st = con.createStatement();
String query = "Select [地区], [办公室], [产品], [业务部], [打开] from [data1$]";

ResultSet rs = st.executeQuery(query);


i also tried executing above code by removing square brackets from query, tried just for one column. And one more thing i notice is yesterday i was getting error ""[Microsoft][ODBC Excel Driver]COUNT field incorrect", today i added "-Dfile.encoding=UTF-8" to my eclipse.ini since then i am getting this error "[Microsoft][ODBC Excel Driver] Too few parameters. Expected 1" for same code. Its very confusing. I am using microsoft excel driver, i am able to fetch data from excel file with data in english with same code and driver
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure of the direct solution, but one workaround would be to "SELECT *" in your query than use integer values in your rs.get<Object>() calls.
 
Neil Jen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott Selikoff wrote:Not sure of the direct solution, but one workaround would be to "SELECT *" in your query than use integer values in your rs.get<Object>() calls.


Hey Scott thanks for your reply and consideration. I tried using "SELECT *" in my query, by this i was able to fetch data but it is not in proper format it shows ??? instead of chinese characters. i am not able to understand whether its problem while fetching data or printing data on console.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic