Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can't read special characters in an excel file using JDBC

807607Oct 17 2006 — edited Oct 17 2006
Hi! I 've a code to read an excel file using JDBC-ODBC bridge. I can read the values, but any special characters is readed wrong, just symbols. The special characters are of spanish language. This is my code:
                Locale currentLocale;
		currentLocale = new Locale("es", "MX");
		Locale.setDefault(currentLocale);

			Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
			c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=comisionesperfiles.xls");
			stmnt = c.createStatement();
			String query = "Select * from [Hoja1$]" ;
			ResultSet rs = stmnt.executeQuery( query );
			while( rs.next() ){
				String valor = rs.getString(2) ;

				if(valor != null && !"null".equalsIgnoreCase(valor)){
					if(!comisiones.contains(valor)){
						System.out.println(valor);
						comisiones.add( valor );
					}
				}
			}
			rs.close();
			stmnt.close();
As you can see, I've tried to set the locale, but it didn't work.
I'm using Excel 2003, Java Version 1.4.2_07 and Windows XP Professional (in latin american spanish).

Hope someone can help me!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 14 2006
Added on Oct 17 2006
2 comments
724 views