View Full Version : JDK versions VS Oracle Driver fo Java versions
Lallo
08-06-2007, 03:28 PM
Hi!
I am building an application in Java that needs to be connected with Oracle 9 database. Regarding this problem I downloaded Oracle Database driver for Java BUT on the site with the drivers there are Drivers for JDK 1.4 the biggest and I have JDK 1.6
Does anyone think that this might be the problem that i get the following error: java.lang.NoClassDeffFoundError: (name of the file)
Before I do the test I put the driver in CLASSPATH - Environment Variable and someone said that it might be wrong. I did it again following guidelines but again the same prob.
Can anyone help me to connect my application with my database please?
Thanks in advance!
Best regards!
Aradon
08-06-2007, 08:47 PM
I don't see how that could be a problem, since in theory 1.6 is backwards compatible to 1.4 (in theory at least).
What are the specific errors that you are getting? As in, when it says no class def found, is it talking about your file that you wrote or the oracle database driver files?
Lallo
08-07-2007, 10:02 AM
I don't see how that could be a problem, since in theory 1.6 is backwards compatible to 1.4 (in theory at least).
What are the specific errors that you are getting? As in, when it says no class def found, is it talking about your file that you wrote or the oracle database driver files?
Oracle database driver.....
:confused::confused::confused::confused::confused::confused::confused::confused::confused::confused:
Lallo
08-07-2007, 01:48 PM
Oracle database driver.....
:confused::confused::confused::confused::confused::confused::confused::confused::confused::confused:
cannot find oracle database driver which is declared as CLASSPATH (ojdbc14.jar)
In some operating systems, you need to restart your computer in order to be able to load changes made to environment variables including CLASSPATH
Having said that though, you might choose to narrow the problem down by uncompressing the contents of the jar file that contains driver class etc into your project directory.
Once you have done that, you should be able to run your application and test whether it was something to do with how you have set the CLASSPATH or not.
Note: does the Oracle database run on the same machine which you are using to build your application. If not, please check that you are able to connect to your database, and that it is not blocked by a firewall from both ends (your developer machine and the machine where you have Oracle installed).
By the way, jar files are similar to zip files...and therefore, you should be able to you use your zip software to uncompress contents of the jdbc driver
Let us know if that works or not.
Lallo
08-08-2007, 10:08 AM
In some operating systems, you need to restart your computer in order to be able to load changes made to environment variables including CLASSPATH
Having said that though, you might choose to narrow the problem down by uncompressing the contents of the jar file that contains driver class etc into your project directory.
Once you have done that, you should be able to run your application and test whether it was something to do with how you have set the CLASSPATH or not.
Note: does the Oracle database run on the same machine which you are using to build your application. If not, please check that you are able to connect to your database, and that it is not blocked by a firewall from both ends (your developer machine and the machine where you have Oracle installed).
By the way, jar files are similar to zip files...and therefore, you should be able to you use your zip software to uncompress contents of the jdbc driver
Let us know if that works or not.
I already tried restarting the machine, but again no. The database is available, although it is on local machine on my network. Now i tried extracting the files from the .jar into my application folder and again i got the same answer
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
I have the print screen of this in the attachment
Anyway thanks for spending your time on my problem :thumbsup:
I will find a solution and I'll let you know!
Regards!
Hello again Lallo,
I think I know why it has not been working for you thus far....and I think it is something to do with NetBeans and the way how it references things internally.
Here is a quote from Netbeans website
"For the IDE to communicate with a database server, the IDE requires a driver supporting the JDBC API ("JDBC driver"), which translates JDBC calls into the network protocols that are used by SQL databases. To work with other databases, you need to install the database server and the JDBC driver"
Basically, you need to add the JDBC driver into the your Netbeans ide. Here is a URL that explains the process of how to add a JDBC driver into netbeans IDE...and test connections before writing any code.
http://www.netbeans.org/kb/50/using-netbeans/dbconn.html
I don't know why Netbeans is not capable of communicating with JDBC drivers if you were to use CLASSPATH as a way to point to a JDBC driver or other java resources.
In any case, please let's know if that worked or not.
Cheers,
Ess
Lallo
08-09-2007, 11:56 AM
Finally I made it and now IT IS WORKING! :thumbsup:
But...
There is another problem.
The data in the database is mostly with Cyrillic characters and when i run query i get the data but in strange characters. I suppose I have problems with the encoding. Example:
Value in the database: Ице И Комерц 3
Value displayed in my application: Ице и Комерц 3
I know that you don't understand my language, but everyone can see the difference...
So any solutions?
Thanks in advance!
Regards, Lallo
You are right..I don't understand your language...but I do know of a solution to your problem.
The problem is to do with character encoding...and it is not really difficult to fix it. you might be interested in reading about Java Localizations from sun microsystems website.
Also, you should localize your application so that it is more aware of the specific localizations for your particular audience.
here is a how you can do this in code
http://www.exampledepot.com/egs/java.util/SetDefLocale.html
The first thing you need to do is to find out how to set character encoding in oracle...I know how in MySql...but not in oracle i am afraid.
the following article goes in details on how you might be able to implement encoding in oracle db. Note: I would recommend that you do a google search...so that you can find something that is more applicable to this problem.
http://blogs.ittoolbox.com/oracle/guide/archives/binary-xml-compressing-encrypting-and-encoding-data-in-oracle-6688
The second thing you need to do is to tell your application the character encoding in use. If you are developing JSP solution, then you can set the character encoding in the browser (outputted html) as well as in your jsp source code....which you should enforce for the purpose of validations and filtering data etc.
Most EU languages are supported by ISO-8859-1 charset...but, please check if your language is supported..etc
please read this url for more info on Java EE Encoding Schemes etc.
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/WebI18N5.html
The following url demonstrates the encodings that are supported by the JVM
http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
let's know if that worked or not.
cheers,
Ess
Lallo
08-09-2007, 11:56 PM
You are right..I don't understand your language...but I do know of a solution to your problem.
The problem is to do with character encoding...and it is not really difficult to fix it. you might be interested in reading about Java Localizations from sun microsystems website.
Also, you should localize your application so that it is more aware of the specific localizations for your particular audience.
here is a how you can do this in code
http://www.exampledepot.com/egs/java.util/SetDefLocale.html
The first thing you need to do is to find out how to set character encoding in oracle...I know how in MySql...but not in oracle i am afraid.
the following article goes in details on how you might be able to implement encoding in oracle db. Note: I would recommend that you do a google search...so that you can find something that is more applicable to this problem.
http://blogs.ittoolbox.com/oracle/guide/archives/binary-xml-compressing-encrypting-and-encoding-data-in-oracle-6688
The second thing you need to do is to tell your application the character encoding in use. If you are developing JSP solution, then you can set the character encoding in the browser (outputted html) as well as in your jsp source code....which you should enforce for the purpose of validations and filtering data etc.
Most EU languages are supported by ISO-8859-1 charset...but, please check if your language is supported..etc
please read this url for more info on Java EE Encoding Schemes etc.
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/WebI18N5.html
The following url demonstrates the encodings that are supported by the JVM
http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
let's know if that worked or not.
cheers,
Ess
Ess, as I underrstand yuo're talking about web applications. The application that I'm building is stand alone application which connects to an oracle database. Anyway I found a way to solve the problem in my way. Here is an example:
String name = new String(rs.getString(1).getBytes("ISO-8859-1"), "windows-1251");
Where:
rs.getString(1) - Is the result set from the previously executed query and the (1) is to "look" in the firs column - irrelevant, with getBytes i get the chars and than i encode them to windows-1251 standard in order to be visible. To get the available charsets i used the following code:
System.out.println(Charset.availableCharsets());
:):):):):):):)
If you want more detailed description of my code I'll give you. :cool:
Best regards and thanks for everything!!!
cash1981
08-10-2007, 02:49 PM
Why not use hibernate? www.hibernate.org
It is much much easier than using JDBC.
Lallo
08-10-2007, 07:04 PM
Why not use hibernate? www.hibernate.org (http://www.hibernate.org)
It is much much easier than using JDBC.
Because I've never heard of it probably :):):)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.