Today, when you do a Java connection database, it appears:
Java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDriver
The error of this hint. Looking carefully, the JDBC driver is not loaded into project.
My code is as follows:
View Plaincopy to Clipboardprint?
try{
Class.forName ("Oracle.jdbc.driver.OracleDriver");
}
catch (Exception e) {
System.out.println (E.getmessage ());
System.exit (-1);
}
try{
Class.forName ("Oracle.jdbc.driver.OracleDriver");
}
catch (Exception e) {
System.out.println (E.getmessage ());
System.exit (-1);
}
This is the kind of error that I have solved:
1, find the database installation file JDBC file, assuming the path is D:/oracle/ora92/jdbc/lib
Add this path to the path of the environment variable.
Right-click My Computer-> advanced-> environment variable, in the system variable path to add the path above.
2, and then add the jar file in the D:/oracle/ora92/jdbc/lib directory to the project.
I'm using JBuilder, so I'll add six jar files under Lib to the library.
Tool->enterprise Setup->database drivers->add->new
In the New Library Wizard Name:jdbc Driver, add in the Library paths, put 6 files in the lib.
Click OK.
3, Project->project properties->paths->required Libraries->add, will just add in the JDBC driver plus
Click OK.
Run the program at this time, OK.
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/bronica_chen/archive/2009/06/12/4264022.aspx