URL string format for connecting to Oracle database with JDBC -
I am a newbie for Java related web development, and I could not find a simple program to work with JDBC Could. I am using off-the-shelf Oracle 10G XE and Eclipse EE IDE, I have so far reduced the problem in an incorrectly written database url or a missing JAR file, from books and web pages of checks. . I am getting the following error:
< P> with the following code:java.sql.SQLException: no suitable driver was found for jdbc: oracle: //127.0.0.1: 8080
import java.sql *; Public square databasestest {public static zero main (string [] args) {string URL = "jdbc: oracle: //127.0.0.1: 8080"; String user name = "hr"; String password = "sample pass"; String SQL = "Employees Select Employees where LAST_NAME = 'King'"; Connection connection; Try {connection = DriverManager.getConnection (URL, Username, Password); Description Details = connection.createStatement (); Println (statement.execute (SQL)); Connection.close (); } Hold (SQLException e) {System.err.println (e); }}}
What is the proper format for database URLs, anyway? He has been told a lot but I have not got any details.
Edit (resolution):
Based on Duffim's answer, I found ojdbc14. Jar
and removed it in the referenced libraries of the Eclipse Project. Then I started the code
... // jdbc: oracle: thin: @
And it worked.
Your URL is quite wrong. You are not registered as a driver class, you must see:
as well. If you want to download thin driver jars, put it in your CLASSPATH and like your code more.
Update: "OzdBC 14.jar" in "14" is for JDK 1.4. You should meet with your driver version JDK which you are running. I'm betting that it means JDK 5 or 6.
Comments
Post a Comment