Jdbc to odbc
I created a db named ClientID with Access first then made a JSP ,the error report say that
java.sql.SQLException: [Microsoft][ODBC Manager] can't find db and default dbdriver ;
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074)
>>>>>>>>>>>>
but when I changed it into application
it works well.what's wrong ?
<%@page import="java.sql.*"%>
<html>
<BODY>
<%String strurl="jdbc:odbc:ClientID";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(strurl) ;
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from client");
%>
<TABLE bgcolor=DodgerBlue>
<B>ClientID</B>
<B>ClientName</B>
<B>City</B>
<%
while(rs.next()){
%>
<%=rs.getString("id")%>
<%=rs.getString("com")%>
<%=rs.getString("city")%>
<%
rs.close();
stmt.close();
conn.close();
%>
</TABLE>
</BODY>
</HTML>
import java.sql.*;
public class Access
public static void main(String args[])
try
String strurl="jdbc:odbc:ClientID";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(strurl) ;
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from client");
while(rs.next())
System.out.println(rs.getString("com"));
}catch(Exception e)
System.out.println(e);
}
angeles1016 : The JdbcOdbc driver is part of the standard java runtime, and shouldn't need to be imported into web-inf/lib.
w1o1s1h1:
You say it works in an application, but not in a jsp page?
Strange. Maybe the Tomcat user has a different priveleges on the system?
Make sure your datasource in the control panels is specified as a SYSTEM level DSN, and not USER.
Another alternative is to define your DSN on the fly:
String strURL = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/data/Access/test1.mdb";
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=200603
Hope this helps,
evnafets
Similar Messages
-
IBM U2 Universe JDBC or ODBC, Can't connect
Hi, I can't find a definite answer on the forums, so I will
post this here. I'm trying to set up a JDBC or ODBC connection to a
Universe 10.0 database.
I've been able to setup both the ODBC and JDBC drivers in
other programs, but coldfusion still isn't working properly.
The ODBC connection will verify, but when you try to do
anything, you get the error "invalid argument value" everytime,
making it useless.
The JDBC connection has offered more success, but is still
useless. SELECT statements work 100% and don't give a problem.
UPDATE, INSERT, or DELETE statements will work and update the
database, but the .cfm page loads constantly until it hits the
timeout period and throws an error. It's like the server is not
responding back from anything but SELECT statements.
If there is any updates on the status of these problems,
please let me know, because I can't find any solid solutions on the
net.No, the JdbcOdbc bridge appears to be calling it.
I'll look for an option; where on earth do I find
documentation on it?Notice the part where I said noted that it might be obscure or not documented at all?
The most likely place is to find the source code for the ODBC driver and hope it has documentation. It might also be documented in the source code itself.
>
Is it allowed to hack the JdbcOdbc code? I was under
the impression that accepting the Sun licence limited
that option. The driver comes with Jdk 1.4. :-$
Yes, as long as you do not distribute it. -
Does TT support OCI API except JDBC and ODBC?
Hi
Does TT support OCI API except JDBC and ODBC? or Do we have any plan to support OCI in the futureOracle policy does not permit us to give any commitment to when or if any specific functionality will be delivered. My understanding is that we plan to deliver this in the next major release of TimesTen (which may or may not be called 8.0) that is released after Oracle 11g (since a lot of the changes needed to enable OCI support for TimesTen are in the 11g client). We currently hope that this release will be available sometime in CY2008.
You should not rely on any of the above information as it is, as always, subject to change without notice.
Chris -
Popularity of JDBC to ODBC or OLEDB
Does anyone know of any statistics about the market share of database applications that use JDBC VS ODBC VS OLEDB (VS native I guess too). I don't mean for this to be a C VS Java question... but more along the lines of what is the breakdown of what percentages of database applications use to connect to the database.
- MarkWell... I am sure Google could find you plenty of statistics but how helpful they will actually be is another matter altogether.
I think there are two problems with most statistics you will find. First of all you have to question the source. Like a study sponsored by Sun will say radically different things from a site sponsored by Microsoft. Will either one be the truth. No. It will be "somewhere" in the middle probably.
Then you have to compare apples to apples as best you can. Your question is way to broad to let that be accomplished. As a guess if I had to guess a the #1 database usage scenario ranked by total number of applications that use it I would guess that the answer is neither JDBC, nor ODBC but the PHP MySQL library.
Now does that mean PHP is better? Well in most cases no. Except in one case it may be... that case being rapid development of relatively simple websites. Occaisonally I read nonsense about how PHP is better than Java but you just can't make that kind of claim. It's like comparing a compact car to a 747 jet. If you want to visit a town 15 miles down the road yes the compact is better. But if you want to go overseas... not so good.
Being able to compare apples to apples is not always easy but the less bias the source has the easier it gets. I am reminded of the netcraft site. They collect information on the usage of different web technologies (and I think sell it) so I would say they are pretty unbiased. At any rate I remember seeing some web server stats that basically showed Linux is far and away the champ when it comes to OS's for hosting the most websites. Windows was second and various Unixy flavours after that. Well down the list was Solaris.
What was interesting though was taking the list of the top 20 or so sites by total traffic. As I recall about 75% of those were on Solaris which was a far different picture than the overall share of less than 5% Okay to be honest I can't remember these numbers for sure but the difference was striking and I would be surprised if I was off by very much and anyway I am just trying to make a point here. The point being that if you asked what is the "best" you get very different answers even from the same set of data depending on how you define best. I think it also makes a strong case that to use volume as an indicator of "bestness" is poor idea.
At any rate I suppose one could find some statistics on JSP vs ASP usage but what that actually tells you I don't know. Let's not forget that they are many, many, many applications running in enterprises around the globe that are not web based so an accounting for these is even harder.
Here is what I would suggest. Try and define better parameters for your question. I would try and look segment by segment of what the application is. Even a breakdown just by web vs non-web would be a good start. Then I would also look to examine the usage by the scale of the application. You need to seperate the little foxpro based VB apps that might sit on someones desk from an enterprise inventory and tracking system. I mean they both use databases but the usage cases are so different... well anyway I'm sure you see the point.
So get some better parameters for your question... otherwise it will be difficult to find data I think (especially that which is both web and non -web together) plus any data you do find will be relatively meaningless.
Hope this helps. -
Hi;
What am I doing wrong and how should I correct it?
I understand that class "Class" is in package java.lang and J2SDK comes with the JDBC-to-ODBC-bridge database driver to allow any Java program to access any ODBC data source. When I code the following
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
I get SQLException runtime error:
[Microsoft][ODBC Driver Manager]Data source name not found and no default driver specified.check your datasource name... i think you probably
defined it yet....
Yes,
In other words, go to control panel, ODBC data sources (or Administrative Tools), and make sure you have an ODBC connection pointed at your database. Make sure you've spelled the ODBC name correctly in your code.
The code you provide is not where the problem is. -
Crystal Reports 2008, mySQL, JDBC, and ODBC
Hello everyone.
I have just spent a very challenging few days getting Crystal Reports 2008 Developer (advanced version) working with a mySQL data source. I fell into several pits and narrowly escaped being eaten by monsters. I thought I'd share my experience to spare others the same trouble. All the stuff I'm writing about here applies to the runtime as well as the Developer UI.
I'm working on Windows Server 2008 R2, 64 bit, standard edition. The mySQL server is 5.1.42. The mySQL ODBC connector is version 5.1.6. You need the 32-bit version of this connector, even if you're on a 64-bit machine.
Lessons learned:
1. JDBC connectivity in Crystal Reports doesn't work correctly. It consumes excessive memory when a report requires lots of rows from a data base. Don't even think about using it.
2. Crystal Reports has a problem with ODBC for mySQL in which it sometimes gives a dialog box with these words in it.
The alias requested 'SOME_TABLE_NAME', contains a combination
of characters which is not considered to be valid.
This error message come up when using items on Crystal's "Database" menu like "Set Datasource Location..."
To fix this you need to make a registry change. As far as I know this has to be done for each account on each machine running the Crystal Developer. (insert usual warning about registry editor). Find the key named:
[HKEY_CURRENT_USER\Software\Business Objects\Suite 12.0\Crystal Reports\Database
Create a new string value named InvalidAliasCharList Give it this value:
.:{}()@&$#^!*~|%\\\"
Notice that the last two characters are backslash double-quote.
Good luck. It actually works pretty well now that it's working.
If any other community member can offer corrections or better ways of coping with this stuff, please do!Good morning,
I was wondering if I may ask some additional help...
We're on version 14.0.4.738 RTM and we are having the same issue.... need to enter the alias as table name with a backslash, ie serparate_work_orders\ for login credential reasons, but all the regedits listed seem to refer to locations in the registry that dont exist.
Version 14 have two "database locations" from what i can see called...
HKEY_CURRENT_USER\Software\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\DatabaseOptions
and
HKEY_CURRENT_USER\Software\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\DatabaseServer
I've applied the patch to both these locations and still no joy, same error message!
Any ideas? -
Jdbc non-odbc-bridge for Access mdb database
I would like to have my Java program be able to use a MicroSoft Access-97 or Access-2000 mdb database. I don't want to use an odbc driver, but instead use a type-2 or 3 or 4 driver (preferrable type-4).
Does such a driver exist? This is for a freeware project, and I would prefer a free or very low cost driver.
I'm not sure I fully understand the differences between jdbc types. My impression is that an odbc-bridge driver requires that the end-user setup the odbc connection. I'd like to avoid that if possible.
My intent is to distribute the application with the MyApp.mdb database file, and have MyApp be able to use the database without user setup.
I suppose an alternative would be to programmatically create the odbc-bridge data source configuration. Is that possible from a java program, and, if so, how? I can do this with Visual C++, but not clear on how to do in JavaSearching the forums is always a good idea.
From one of the previous times I answered this.
http://forum.java.sun.com/thread.jsp?forum=48&thread=199027 -
without odbc
there is a possible to connect
any database
-sun_jothiodbc is an older standard that doesn't have anything to do with Java.
JDBC is the Java-equivalent to ODBC, it's a Java-based standard. There are JDBC drivers that are based on ODBC (so called JDBC-ODBC-bridges), but they are usually of bad quality and only usefull for testing/experimentation). Most Databases provide JDBC drivers that don't depend on ODBC in any way. -
Hi
2 quick beginner questions:
1. Can you use odbc with java
2. How does JDBC compare with ODBC performance wise.
Thanks in advance2 quick answers:
1. You can use the JDBC-ODBC bridge.
2. In this case it's a wrapper over ODBC only. But the bridge is a real Java driver.
Some people supported god experiences with it, for example jschell here:
http://forums.java.sun.com/thread.jsp?forum=48&thread=213474
Feel free to ask more specific, when you have begun.
Good luck! -
JDBC-ODBC Bridge to SPSS data files - Result Set Type is not supported
Hello,
As mentioned in the subject I am trying to read SPSS data files using the SPSS 32-Bit data driver, ODBC and the JDBC-ODBC Bridge.
Using this SPSS Driver I manged to read the data directly into an MS-SQL Server using:
SELECT [...] FROM
OPENROWSET(''MSDASQL.1'',''DRIVER={SPSS 32-BIT Data Driver (*.sav)};DBQ=' SomePathWhereTheFilesAre';SERVER=NotTheServer'', ''SELECT 'SomeSPSSColumn' FROM "'SomeSPSSFileNameWithoutExt'"'') AS a
This works fine!
Using Access and an ODBC System DNS works for IMPORTING but NOT for LINKING.
It is even possible to read the data using the very slow SPSS API.
However, when it comes to JDBC-ODBC the below code does only work in part. The driver is loaded successfully, but when it comes to transferring data into the resultset object the error
SQLState: null
Result Set Type is not supported
Vendor: 0
occurs.
The official answer from SPSS is to use .Net or to use their implementation with Python in their new version 14.0. But this is obviously not an option when you want to use only Java.
Does anybody have experience with SPSS and JDBC-ODBC??? I have tried the possible ResultSet Types, which I took from:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/rjvdsprp.htm
and none of them worked.
Thank you in advance for your ideas and input & stay happy!
Here the code without all the rest of the class arround it:
// Module: SimpleSelect.java
// Description: Test program for ODBC API interface. This java application
// will connect to a JDBC driver, issue a select statement
// and display all result columns and rows
// Product: JDBC to ODBC Bridge
// Author: Karl Moss
// Date: February, 1996
// Copyright: 1990-1996 INTERSOLV, Inc.
// This software contains confidential and proprietary
// information of INTERSOLV, Inc.
public static void main1() {
String url = "jdbc:odbc:SomeSystemDNS";
String query = "SELECT SomeSPSSColumn FROM 'SomeSPSSFileName'";
try {
// Load the jdbc-odbc bridge driver
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
DriverManager.setLogStream(System.out);
// Attempt to connect to a driver. Each one
// of the registered drivers will be loaded until
// one is found that can process this URL
Connection con = DriverManager.getConnection (url);
// If we were unable to connect, an exception
// would have been thrown. So, if we get here,
// we are successfully connected to the URL
// Check for, and display and warnings generated
// by the connect.
checkForWarning (con.getWarnings ());
// Get the DatabaseMetaData object and display
// some information about the connection
DatabaseMetaData dma = con.getMetaData ();
System.out.println("\nConnected to " + dma.getURL());
System.out.println("Driver " +
dma.getDriverName());
System.out.println("Version " +
dma.getDriverVersion());
System.out.println("");
// Create a Statement object so we can submit
// SQL statements to the driver
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_READ_ONLY);
// Submit a query, creating a ResultSet object
ResultSet rs = stmt.executeQuery (query);
// Display all columns and rows from the result set
dispResultSet (rs);
// Close the result set
rs.close();
// Close the statement
stmt.close();
// Close the connection
con.close();
}Thank you for your reply StuDerby!
Actually the above script was before, as you suggested, leaving the ResultSetTeype default. This did not work...
I am getting gray hair with SPSS - in terms of connectivity and "integratebility" none of their solutions offered is sufficient from my point of view.
Variable definitions can only be read by the slow API, data can only be read by Python or Microsoft Products... and if you want to combine both you are in big trouble. I can only assume that this is a company strategy to sell their Dimensions Platform to companies versus having companies developping their applications according to business needs.
Thanks again for any furthur suggestions and I hope, that some SPSS Developper will see this post!
Cheers!! -
Problems with JDBC-ODBC Driver
Hello,
I am trying to access a DSN on my windows with a dedicated DB driver of some company. so i used the JDBC-ODBC connector.
when launching the java code, and debugging the problem i get the following error:
DriverManager.getConnection("jdbc:odbc:priority32;UID=Manager;PWD=keren")
trying driver--className=com.mysql.jdbc.Driver,com.mysql.jdbc.Driver@16caf43--
trying driver--className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@66848c--
*Driver.connect (jdbc:odbc:priority32;UID=Manager;PWD=keren)
JDBC to ODBC Bridge: Checking security
No SecurityManager present, assuming trusted application/applet
JDBC to ODBC Bridge 2.0001
Current Date/Time: Tue Aug 12 07:50:37 VET 2008
Loading JdbcOdbc library
Allocating Environment handle (SQLAllocEnv)
hEnv=50338088
Allocating Connection handle (SQLAllocConnect)
hDbc=50338256
Connecting (SQLDriverConnect), hDbc=50338256, szConnStrIn=DSN=priority32;UID=Manager;PWD=keren
*Connection.getMetaData
*DatabaseMetaData.getDriverName
Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=6, len=300
tabula.dll
*DatabaseMetaData.getDriverVersion
Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=7, len=300
07.00.0000
*DatabaseMetaData.getDriverName
Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=6, len=300
tabula.dll
Driver name: JDBC-ODBC Bridge (tabula.dll)
*DatabaseMetaData.getDriverVersion
Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=7, len=300
07.00.0000
Driver version: 2.0001 (07.00.0000)
Caching SQL type information
*Connection.getMetaData
*DatabaseMetaData.getTypeInfo
Allocating Statement Handle (SQLAllocStmt), hDbc=50338256
hStmt=50339424
Get type info (SQLGetTypeInfo), hStmt=50339424, fSqlType=0
Number of result columns (SQLNumResultCols), hStmt=50339424
value=15
Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=10, len=300
03.52.0000
Fetching (SQLFetch), hStmt=50339424
Column attributes (SQLColAttributes), hStmt=50339424, icol=1, type=2
value (int)=12
Column attributes (SQLColAttributes), hStmt=50339424, icol=1, type=3
value (int)=129
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
CHAR
Get integer data (SQLGetData), hStmt=50339424, column=2
value=12
Get integer data (SQLGetData), hStmt=50339424, column=3
value=0
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
CHAR(1)
Get integer data (SQLGetData), hStmt=50339424, column=2
value=1
Get integer data (SQLGetData), hStmt=50339424, column=3
value=0
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
RCHAR
Get integer data (SQLGetData), hStmt=50339424, column=2
value=12
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
REAL
Get integer data (SQLGetData), hStmt=50339424, column=2
value=6
Get integer data (SQLGetData), hStmt=50339424, column=3
value=0
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
INT
Get integer data (SQLGetData), hStmt=50339424, column=2
value=4
Get integer data (SQLGetData), hStmt=50339424, column=3
value=0
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
UNSIGNED
Get integer data (SQLGetData), hStmt=50339424, column=2
value=4
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
TIME
Get integer data (SQLGetData), hStmt=50339424, column=2
value=10
Get integer data (SQLGetData), hStmt=50339424, column=3
value=0
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
DATE
Get integer data (SQLGetData), hStmt=50339424, column=2
value=11
Get integer data (SQLGetData), hStmt=50339424, column=3
value=0
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
DATE
Get integer data (SQLGetData), hStmt=50339424, column=2
value=9
Get integer data (SQLGetData), hStmt=50339424, column=3
value=0
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
DAY
Get integer data (SQLGetData), hStmt=50339424, column=2
value=4
Fetching (SQLFetch), hStmt=50339424
Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
DECIMAL
Get integer data (SQLGetData), hStmt=50339424, column=2
value=3
Get integer data (SQLGetData), hStmt=50339424, column=3
value=0
Fetching (SQLFetch), hStmt=50339424
End of result set (SQL_NO_DATA)
*ResultSet.close
Free statement (SQLFreeStmt), hStmt=50339424, fOption=1
*ResultSet has been closed
Get connection info (SQLGetInfo), hDbc=50338256, fInfoType=44
int value=0
Get connection info (SQLGetInfo), hDbc=50338256, fInfoType=121
RETCODE = -1
ERROR - Generating SQLException...
SQLState(S1096) vendor code(0)
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Information type out of range
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetInfo(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.checkBatchUpdateSupport(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at WigsUpdate.main(WigsUpdate.java:25)
getConnection returning driver--className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@66848c--what can be done?
thank you very muchHimberJack wrote:
oh now i understand.
i got a very unknown company which supplied the ODBC driver, but they dont have java driver...
so I have nothing to do about it?The choices are find a different driver or use the one you have.
The one you have doesn't do batches.
Finding a different driver could involve the following.
- Buying one from somewhere else
- Pay someone to write one.
- Write a driver yourself.
All of those are somewhat dependent that the "unknown company" has an API that supports that. You (or someone) could also figure out the file format of the "unknown company" as well and then write one. -
Is it better to use one over the other? Will ODBC allow me to pull data more quickly over the network? Right now I'm using JDBC and the fetch size is set to 10,000 and batch is 100 but the network utilization is about 4% of total bandwidth. It looks like this is because of the fetch size? If I switch to ODBC will I utilize more of the bandwidth available then?
I have a front end application (Tibco Spotfire) which connects to Oracle Exadata via JDBC right now. The network utilization on the Exadata and application size is very low right now but I do pull a lot of data to the application and it takes quite sometime (20-30min) to grab all the rows AFTER the query is done processing. Trying to see if I can speed up the data transfer from Exadata to the application.sybrand_b wrote:
sqlnet (which is used both by JDBC and ODBC) transmits data in packets.
When your array is bigger than a packet, sqlnet will fragment your array automatically.
For sure an array of 10000 is WAY too big.
The number of elements times the number of bytes in a record should not exceed 2048 (default SDU)
or 32767 (max SDU).
Also SDU should be a multiple of the NIC's MTU.
Sybrand Bakker
Senior Oracle DBA
The array size can have a huge effect on performance, you probably need to set it as high as you can for this sort of situation. Here is an example:
orcla>
orcla> set autot trace stat
orcla> set timing on
orcla> set arraysize 5000
orcla> select * from all_objects;
73050 rows selected.
Elapsed: 00:00:00.65
Statistics
107 recursive calls
0 db block gets
17668 consistent gets
0 physical reads
0 redo size
2910414 bytes sent via SQL*Net to client
677 bytes received via SQL*Net from client
16 SQL*Net roundtrips to/from client
779 sorts (memory)
0 sorts (disk)
73050 rows processed
orcla> set arraysize 1
orcla> select * from all_objects;
73050 rows selected.
Elapsed: 00:00:02.51
Statistics
107 recursive calls
0 db block gets
59624 consistent gets
0 physical reads
0 redo size
9591744 bytes sent via SQL*Net to client
402287 bytes received via SQL*Net from client
36526 SQL*Net roundtrips to/from client
779 sorts (memory)
0 sorts (disk)
73050 rows processed
orcla> -
Retrieval of Information from Excel Sheet using JDBC-ODBC
Hello,
Currently I am writing a program that extracts information fromexcel sheet. This excel sheet have some values in Chinese. I am able to extract English character from the different column in excel, but if some column contain chineese valur then it prints ???. After that I looked on net and found some details in to convert Big5 (Chinese) character into unicode, but this is not working and in that case nothing is displayed. I am attaching the my code. In my code the 'customer' field contain chinese character.
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.Reader;
import java.io.IOException;
import java.sql.*;
public class ExcelJDBC
Connection con;
Statement stmt;
public ExcelJDBC(String url)
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(java.lang.ClassNotFoundException e)
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
try
con = DriverManager.getConnection(url, "", "");
stmt = con.createStatement();
catch(SQLException ex)
System.out.println("SQL EXCEPTION OCCURED");
System.err.println("SQLException: " + ex.getMessage());
ex.printStackTrace();
public void sql(String sql)
try
stmt.execute(sql);
catch(SQLException ex)
System.out.println("SQL EXCEPTION OCCURED");
System.err.println("SQLException: " + ex.getMessage());
ex.printStackTrace();
public void closeAll()
try
stmt.close();
con.close();
catch(SQLException ex)
System.out.println("SQL EXCEPTION OCCURED");
System.err.println("SQLException: " + ex.getMessage());
ex.printStackTrace();
//big5 to unicode conversion
private String b2u(String str2convert) throws IOException
System.out.println("The input string is :" + str2convert);
StringBuffer buffer = new StringBuffer();
byte[] targetBytes = str2convert.getBytes();
ByteArrayInputStream stream = new ByteArrayInputStream(targetBytes);
InputStreamReader isr = new InputStreamReader(stream,"Big5");
Reader in = new BufferedReader(isr);
int chInt;
while((chInt = in.read()) < -1)
buffer.append((char)chInt);
in.close();
System.out.println("The output string is :" + buffer.toString());
return buffer.toString();
public void sqlQuery(String sql)
try
ResultSet rc = stmt.executeQuery(sql);
if(rc != null)
int count = 0;
while (rc.next())
String value = "";
value = b2u(rc.getString("workorder"));
System.out.println("The workorder is : "+value);
String customer = rc.getString("Customer");
value = b2u(customer);
System.out.println("The Customer is : "+value);
count++;
System.out.println("Entering in loop " count " time.\n");
catch(SQLException ex)
System.out.println("SQL EXCEPTION OCCURED");
System.err.println("SQLException: " + ex.getMessage());
ex.printStackTrace();
catch(IOException ex)
System.out.println("IO EXCEPTION OCCURED");
System.err.println("IOException: " + ex.getMessage());
ex.printStackTrace();
public static void main(String[] args)
String url = "jdbc:odbc:detailsdsn";
try
ExcelJDBC ej = new ExcelJDBC(url);
ej.sqlQuery("SELECT \"workorder\", \"Customer\" FROM \"Sheet1$\"");
ej.closeAll();
catch(Exception ex)
System.out.println("SQL EXCEPTION OCCURED");
System.err.println("SQLException: " + ex.getMessage());
ex.printStackTrace();
I will highly appriciate any answer of my problem.
Regards,
RuchiTry to find out, what characters really are in your string customer.
I assume you used System.out.print..(), when you got them as '?'.
Find out which unicodes they are!
Afterwards I see two possibilites:
Either
1) you see real unicodes for Chinese characters, and it was only the unability of System.out to print them others than as '?', then you can convert these characters however you want. Maybe your further processing can handle them directly as unicode.
or
2) you get really '?' in your string. Then Excel (or JDBC or ODBC or ???) hasn't been able to transmit these Chinese characters to your program others than converting them all into '?'. Then you are lost, because you can't know which Chinese character each '?' originally could have been.
Hope this helps.
Please tell us, which you experienced, 1) or 2). -
ODBC vs JDBC differences??
Not sure if this is the right place . . .
I'm not a DBA, but in general here is my question:
If I'm calling the same stored procedure with the same data through JDBC and ODBC could there be a difference in results?
I'm wondering about record level lock detection?? Could it react different between JDBC and ODBC?
Thanks,
MarkHi,
The query sent to Oracle database using JDBC or ODBC will result in same output if they are sent at same time. Query sent at different time will result in different result due to database changes and Oracle read consistency model.
JDBC or ODBC will not matter.
Regards -
ColdFusion 9 ODBC Connection Issue
I have a 64 bit ODBC (OpenEdge/Progress) driver installed and it works fine in other applications but when I try to register the DSN in ColdFusion it gives me the error listed below. I've tried to research this error and everything I found and tried has not worked. Any ideas on what the issue is or how to resolve it?
java.sql.SQLException: [Macromedia][SequeLink JDBC Driver][ODBC Socket]internal error: The specified DSN contains an architecture mismatch between the Driver and Application
The root cause was that: java.sql.SQLException: [Macromedia][SequeLink JDBC Driver][ODBC Socket]internal error: The specified DSN contains an architecture mismatch between the Driver and ApplicationNever seen the error before, but an "architecture mismatch" would imply you're trying to use a 64-bit driver with 32-bit ColdFusion.
What's the setup of the server?
O.
Maybe you are looking for
-
Cannot view .psd files in Preview since upgrading to Leopard
Last week I upgraded my iBook G4 to Leopard 10.5.6. I've noticed that since the upgrade, I can no longer view any .psd files in Preview. I could do this with Tiger, but in Leopard all I get is a question mark symbol instead of an image. I deleted the
-
Any way to avoid FCP taking HNC150 (AVCHD) footage straight to DVD?
I have some footage shot on the HMC150, then transfered to HDD that I need to go straight to DVD with. Is there a decent way to go to DVDSP with this footage? I would like to avoid the FCP>ProRes>Compressor>DVDSP trip if possible. A client just needs
-
Imported photos from old mac now cant export onto new Macq
Ok so here is the deal. I was in Iraq and I put all my photos from my Macbook I had to my iPhone. Now the hard drive in that thing crapped out so I bought a iMac the other day. Nice computer for $1700. But with all this money I have spent on this wor
-
I am trying to capture SQL query being submitted to the Oracle Server (8i) being sent by a C++ program. Any ideas on how to get the information from Oracle? Any hint will be appreciated. null
-
AIA recommends to provide _CUSTOM.XSL along with regular transformation xsl file for customers to add their custom transformation. It says, make a callout to the template in custom.xsl as follows <xsl:call-template name="SenderType_ext"> <xsl:with-pa