jdbc驅動在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 resultset, Object obj, Connection connection)
{
if (resultset != null)
try
{
resultset.close();
resultset = null;
}
catch (SQLException 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);
}
}