# java and oracle connection



## incorrigible (Jul 3, 2002)

Hello

I have made tables in oracle and im tryin g 2 connect these tables to java where i have made forms. i havent downloaded any driver but i think when i installed Oracle 8.1.7 it had jdbc drivers too. im tryin to run a separate code which checks the connection. It keeps giving an error saying that the" specified driver does not exist". 
here is the code , hope somebody can help me


```
import java.sql.*;
import java.util.*;

public class MyConnection
{
	Connection con;
	MyConnection()
	{
		try
		{

                  Class.forName("oracle.jdbc.driver.OracleDriver");
                  con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:Orahome","scott","tiger");

// ******************************Connected To Jdbc-Odbc Type - 1 Driver
/*
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//			con = DriverManager.getConnection("Jdbc:Odbc:dsnname","userid","password");
			con = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=servername;Database=pubs","userid","password");
*/
// ******************************Connected To Ms-Access JDBC ODBC Driver .
/*
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			con = DriverManager.getConnection("Jdbc:Odbc:dsnname","","");
//			con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=G:/admin.mdb","","");
*/

// ******************************Connected To Ms-Access Type-3 Driver.

	/*		Class.forName ("acs.jdbc.Driver");
			String url = "jdbc:atinav:servername:5000:C:\\admin.mdb";
			String username="Admin";
			String password="";
			Connection con = DriverManager.getConnection(url,username,password);
*/
// ******************************Connected To Microsoft SQL.
/*
			Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
			con = DriverManager.getConnection("jdbc:microsoft:sqlserver://servername:1433","userid","password");
// ******************************Connected To Merant.
/*
			Class.forName("com.merant.datadirect.jdbc.sqlserver.SQLServerDriver");
			con = DriverManager.getConnection("jdbc:merant:sqlserver://servername:1433;User=userid;Password=password");
*/
// ******************************Connected To Atinav SqlServer.
/*
			Class.forName ("net.avenir.jdbc2.Driver");
			con= DriverManager.getConnection("jdbc: AvenirDriver://servername:1433/pubs","userid","password");
*/
// ******************************Connected To J-Turbo.
/*			String server="servername";
			String database="pubs";
			String user="userid";
			String password="password";

			Class.forName("com.ashna.jturbo.driver.Driver");
			con= DriverManager.getConnection("jdbc:JTurbo://"+server+"/"+database,user,password);
*/
/*// ******************************Connected To jk Jdbc Driver.
			String url= "jdbc:jk:[email protected]:1433";
			Properties prop = new Properties();
			prop.put("user","userid");//Set the user name
			prop.put("password","password");//Set the password

			Class.forName ("com.jk.jdbc.Driver").newInstance();
			con = DriverManager.getConnection (url, prop);*/

// ******************************Connected To jNetDirect Type - 4 Driver
/*			String sConnect = "jdbc:JSQLConnect://127.0.0.1/database=pubs&user=userid&password=password";
			Class.forName ("com.jnetdirect.jsql.JSQLDriver").newInstance();
			Connection con= DriverManager.getConnection(sConnect);
*/
// ******************************Connected To AvenirDriver Type - 4 Driver

//			String url= "jdbc: AvenirDriver: //servername:1433/pubs";
//			java.util.Properties prop = new java.util.Properties ();
//			prop.put("user","userid");
//			prop.put("password","password");
/*			Class.forName ("net.avenir.jdbc2.Driver");
			System.out.println(" Connected To AvenirDriver Type - 4 Driver");
			con= DriverManager.getConnection("jdbc: AvenirDriver://servername:1433/pubs","userid","password");
*/
// ******************************Connected To iNet Sprinta2000 Type - 4 Driver
	/*		String url="jdbc:inetdae7:servername:1433";
			String login="userid";
			String password="password";
			Class.forName("com.inet.tds.TdsDriver");
			System.out.println(" Connected To iNet Sprinta2000 Type - 4 Driver");
			con=DriverManager.getConnection(url,login,password);
*/
// ******************************Connected To iNet Opta2000 Type - 4 Driver
/*			String url="jdbc:inetdae7:servername:1433";
			String login="sagar";
			String password="sagar";
			Class.forName("com.inet.tds.TdsDriver").newInstance();
			System.out.println(" Connected To iNet Opta2000 Type - 4 Driver");
			con=DriverManager.getConnection(url,login,password);
*/
			DatabaseMetaData md = con.getMetaData();

			System.out.println("Driver Name            " + md.getDriverName());
			System.out.println("Driver Version         " + md.getDriverVersion());
			System.out.println("Database URL is        " + md.getURL());
			System.out.println("Database UserName is   " + md.getUserName());
			System.out.println("Connection Name        " + md.getConnection());
			System.out.println("Database Name          " + md.getDatabaseProductName());
			System.out.println("Database Version       " + md.getDatabaseProductVersion());
			System.out.println("Database ReadOnly Type " + md.isReadOnly());
			System.out.println("MaxColumnNameLength    " + md.getMaxColumnNameLength());
			System.out.println("MaxConnections         " + md.getMaxConnections());
			System.out.println("");

		}
		catch(ClassNotFoundException cnfe)
		{
			System.out.println(cnfe.getException());
			System.out.println("The Specified Driver Does not Exist....");
		}
		catch(SQLException sqle)
		{
			if(sqle.getErrorCode() == 0)
				System.out.println("No Suitable Driver Found..");
			else if(sqle.getErrorCode() == 1017)
				System.out.println("Wrong UserName Or Password..");
			else if(sqle.getErrorCode() == 1034)
				System.out.println("Database not Started..");
				System.out.println(sqle.getErrorCode());
				System.out.println(sqle.getSQLState());
				System.out.println(sqle);
		}
	}
	public static void main (String args[])
	{
		new MyConnection();
	}
}
```
i still get the same error msg. tht the specified driver does not exist.

i have in my classpath - CLASSPATH=.;[ORACLE_HOME]jdbc\lib\classes12.zip
and in my variable ORACLE_HOME AND it s value - C:\oracle\ora81

the error that i get is

C:\Program Files\JBuilder\jdk1.4\bin\javaw -classpath "C:\Documents and Settings\Administrator\jbproject\classes;C:\Program Files\JBuilder\jdk1.4\demo\jfc\Java2D\Java2Demo.jar;C:\Program Files\JBuilder\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\charsets.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\ext\dnsns.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\ext\ldapsec.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\ext\localedata.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\ext\sunjce_provider.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\im\indicim.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\jaws.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\jce.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\jsse.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\rt.jar;C:\Program Files\JBuilder\jdk1.4\jre\lib\sunrsasign.jar;C:\Program Files\JBuilder\jdk1.4\lib\dt.jar;C:\Program Files\JBuilder\jdk1.4\lib\htmlconverter.jar;C:\Program Files\JBuilder\jdk1.4\lib\tools.jar" MyConnection 
null
The Specified Driver Does not Exist....


----------

