The JDBC driver can be found in c: \ oracle \ ora92 \ JDBC \ Lib \ ojdbc14.jar.
Package JDBC;
Import java. SQL. connection;
Import java. SQL. drivermanager;
Import java. SQL. resultset;
Import java. SQL. sqlexception;
Import java. SQL. statement;
Public class Test2
{
Private Static connection con = NULL;
Public Test2 ()
{
}
Public static final connection getcon ()
{
String forname = "oracle. JDBC. Driver. oracledriver ";
String url = "JDBC: oracle: thin: @ 192.168.10.23: 1521: Test ";
String user = "system ";
String Password = "headfree ";
Try
{
Class. forname (forname). newinstance ();
Con = drivermanager. getconnection (URL, user, password );
}
Catch (exception E)
{
E. printstacktrace ();
}
Return con;
}
Public static final void close (resultset, object OBJ, connection)
{
If (resultset! = NULL)
Try
{
Resultset. Close ();
Resultset = NULL;
}
Catch (sqlexception)
{
}
If (OBJ! = NULL & (OBJ instanceof statement ))
Try
{
(Statement) OBJ). Close ();
OBJ = NULL;
}
Catch (sqlexception sqlexception1)
{
}
If (connection! = NULL)
Try
{
Connection. Close ();
Connection = NULL;
}
Catch (sqlexception sqlexception2)
{
}
}
Public static void main (string ARGs [])
{
Connection conn = test2.getcon ();
If (Conn! = NULL)
{
System. Out. println ("successful ");
}
JDBC. test2.close (null, null, con );
}
}