需要的资源:服务器上装一个oracle就有了
oracle的文档里有JDBC驱动连接的一切代码及说明,明天copy一段代码给你

解决方案 »

  1.   

    http://www.csdn.net/expert/topic/94/94959.shtm
      

  2.   

    给你一个较详细的bean
    package com.db.oracle;
    import java.sql.*;
    import java.io.*;
    import javax.sql.*;
    public class DB
    {
    protected Connection m_sqlConn;// 数据库连接对象
    protected Statement m_sqlStmt;// 语句对象
    protected String m_strDriver;
    protected String m_strConURL;
    protected String m_strSqlUser;
    protected String m_strSqlPass;
    protected String m_strDatabase;
    protected String m_strServerIP;
    protected String m_strServerPort;
    protected String m_strCharSet;
    protected String m_strSql;

    public DB()
    {
    this.m_sqlConn = null;
    this.m_sqlStmt = null;
    this.m_strDriver = "oracle.jdbc.driver.OracleDriver";
    this.m_strConURL = "jdbc:oracle:oci8:@";
    this.m_strSqlUser = "youruid";
    this.m_strSqlPass = "youruidpwd";
    this.m_strDatabase = "yourdbname";
    this.m_strServerIP = "yourIP";
    this.m_strServerPort = "1521";
    this.m_strCharSet = "GB2312"; this.m_strSql = "";
    }
    public static void log(String p_strLog) 
    {
    System.out.println(new java.util.Date() + ":" + p_strLog);
    }
    public Connection connectToDB() throws SQLException, java.lang.ClassNotFoundException, 
    java.lang.IllegalAccessException, java.lang.InstantiationException/*,javax.naming.NamingException*/
    {
    try
    {
    m_strConURL += m_strDatabase;
    Class.forName(m_strDriver).newInstance();
    m_sqlConn = DriverManager.getConnection(m_strConURL, m_strSqlUser, m_strSqlPass);
    m_sqlStmt = m_sqlConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    }
    catch(java.lang.InstantiationException e)
    {
    log("DB.connectToDB error, InstantiationException:" + e.getMessage());
    throw e;
    }
    catch(java.lang.IllegalAccessException e)
    {
    log("DB.connectToDB error, IllegalAccessException:" + e.getMessage());
    throw e;
    }
    catch(java.lang.ClassNotFoundException e)
    {
    log("DB.connectToDB error, ClassNotFoundException:" + e.getMessage());
    throw e;
    }
    catch(SQLException e)
    {
    log("DB.connectToDB error, SQL Exception:" + e.getMessage());
    throw e;
    }
    finally
    {
    return m_sqlConn;
    }
    }
    public boolean closeStatement() throws NullPointerException, SQLException
    {
    boolean bReturn = true;
    try
    {
    m_sqlStmt.close();
    m_sqlStmt = null;
    }
    catch(NullPointerException e)
    {
    log("DB.closeStatement error, DB的成员:m_sqlStmt是空值。:" + e.getMessage());
    bReturn = false;
    throw e;
    }
    catch(SQLException e)
    {
    log("DB.closeStatement error, SQLException:" + e.getMessage());
    bReturn = false;
    throw e;
    }
    finally
    {
    return bReturn;
    }
    }


    public boolean closeConnection() throws NullPointerException, SQLException
    {
    boolean bReturn = true;
    try
    {
    m_sqlConn.close();
    m_sqlConn = null;
    }
    catch(NullPointerException e)
    {
    log("DB.closeConnection error, DB的成员:m_sqlConn是空值。:" + e.getMessage());
    bReturn = false;
    throw e;
    }
    catch(SQLException e)
    {
    log("DB.closeConnection error, SQLException:" + e.getMessage());
    bReturn = false;
    throw e;
    }
    finally
    {
    return bReturn;
    }
    }

    public boolean close() throws NullPointerException, SQLException
    {
    if (closeStatement() && closeConnection())
    {
    return true;
    }else{
    return false;
    }
    }

    public void setAutoCommit(boolean bAuto) throws NullPointerException, SQLException
    {
    try
    {
    m_sqlConn.setAutoCommit(bAuto);
    }
    catch(NullPointerException e)
    {
    log("DB.setAutoCommit error, DB的成员:m_sqlConn是空值。:" + e.getMessage());
    throw e;
    }
    catch(SQLException e)
    {
    log("DB.setAutoCommit error, SQLException:" + e.getMessage());
    throw e;
    }
    }


    public void commit() throws NullPointerException, SQLException
    {
    try
    {
    m_sqlConn.commit();
    }
    catch(NullPointerException e)
    {
    log("DB.commit error, DB的成员:m_sqlConn是空值。:" + e.getMessage());
    throw e;
    }
    catch(SQLException e)
    {
    log("DB.commit error, SQLException:" + e.getMessage());
    throw e;
    }
    }


    public ResultSet executeQuery(String strSql) throws NullPointerException, SQLException
    {
    ResultSet setRet = null;
    try
    {
    m_strSql = strSql;
    setRet = m_sqlStmt.executeQuery(strSql);
    }
    catch(NullPointerException e)
    {
    log("DB.executeQuery error, DB的成员:m_sqlStmt是空值。:" + e.getMessage());
    throw e;
    }
    catch(SQLException e)
    {
    log("DB.executeQuery error, SQLException:" + e.getMessage());
    log("SQL语句是:" + strSql);
    throw e;
    }
    finally
    {
    return setRet;
    }
    }

    public int executeUpdate(String strSql) throws NullPointerException, SQLException
    {
    int iRet = 0;
    try
    {
    m_strSql = strSql;
    iRet = m_sqlStmt.executeUpdate(strSql);
    }
    catch(NullPointerException e)
    {
    iRet = -1;
    log("DB.executeUpdate error, DB的成员:m_sqlStmt是空值。:" + e.getMessage());
    throw e;
    }
    catch(SQLException e)
    {
    iRet = -1;
    log("DB.executeUpdate error, SQLException:" + e.getMessage());
    log("SQL语句是:" + strSql);
    throw e;
    }
    finally
    {
    return iRet;
    }
    }
      

  3.   

    请问支持JDK1.3的ORACLE驱动哪里有?
      

  4.   

    这个驱动是ORACLE8带的,那低版本的ORACLE好象不自带驱动吧!那哪里有呢?