tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From LERBSCHER Jean-Pierre <jean-pierre.lerbsc...@cofiroute.fr>
Subject RE : OCI Driver Usage [RE: Oracle 9i client connection to 8i data base]
Date Wed, 05 Jan 2005 13:40:45 GMT
To use thin driver, you just have to put jdbc library on your classpath
(ojdbc14.jar for oracle9), depending on your configuration, deploy this jar
in common/lib, or war file.

You can try this code. I did not compile it but I think that it must run.

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

public class Test 
{
	static String _url = "jdbc:oracle:thin:@host:port:sid";
	static String url;
	
	String login ;
	String password ;
	
	Connection con;
	PreparedStatement  stmt;

	/**
	 * MAIN()
	 * @param args
	 */
	public static void main(String args[]) 
	{		
		if (args.length < 3 ) 
		{
			System.out.println("usage: java Test -Durl=<url>
<login> <password>");
			System.exit(1);
		}
		
		url = System.getProperty( "url" , _url );
		
		Test ts = new Test();
		
		ts.login = args[0];
		ts.password = args[1];
		
		ts.doTest();
	}

	/**
	 * Constructeur par défaut.
	 *
	 */
	public Test()
	{
		try {
	
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
			
		} catch(Exception e) {
			System.out.println("Exception: ");
			System.out.println(e.getMessage());
		}
	}

	/**
	 * 
	 *
	 */
	public void doTest()
	{

		System.out.println("----------- parameters -------------");
		System.out.println("URL : " + url );
		System.out.println("login : " + login );
		System.out.println("password : " + password );
		System.out.println("-----------------------------------");
		
		try {
					con = DriverManager.getConnection(
url, login, password );
			
					// Create Oracle DatabaseMetaData
object 
					DatabaseMetaData meta =
con.getMetaData (); 
					//  get driver info: 
					System.out.println("JDBC driver
version is " + meta.getDriverVersion());
		} 
		catch(SQLException ex) 
		{
			System.out.println("SQLException: " +
ex.getMessage());
		}
		finally
		{
			try {
				if ( stmt != null ) stmt.close();
				if ( con != null ) con.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}

	}
}

-----Message d'origine-----
De : Brad Rhoads [mailto:brad@zethcon.com] 
Envoyé : mercredi 5 janvier 2005 14:05
À : 'Tomcat Users List'
Objet : OCI Driver Usage [RE: Oracle 9i client connection to 8i database]

 

> -----Original Message-----
> From: LERBSCHER Jean-Pierre 
> [mailto:jean-pierre.lerbscher@cofiroute.fr] 
> Sent: Wednesday, January 05, 2005 3:14 AM
* Perhaps you have to try 
> jdbc:oracle:oci:@<service_name> with oci driver.
> 
> > -----Original Message-----
> > From: Michael Echerer [mailto:mech@tngtech.com]
> > Sent: Saturday, December 25, 2004 4:08 AM
> > To: Tomcat Users List
> > Subject: Re: Oracle 9i client connection to 8i database
> > 
> > How come that you need an Oracle client installation at all
> > when you just want to use the Oracle thin JDBC driver? IHMO 
> > the client installation is only required for OCI thick drivers...


What do I need to do to try out the OCI drivers?

Will my existing code work? 

Anyone have an example?



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message