你把class12.jar这个文件放到你的classpath路径里面去

解决方案 »

  1.   

    首先你要把class12.jar驱动文件放在%java_home%\lib里面,如果是class12.rar或者class12.zip要重命名为class12.jar jdbcDriver = "oracle.jdbc.driver.OracleDriver";
    Class.forName(jdbcDriver);不是oracle.jdbc.OracleDriver
      

  2.   

    恩 ~ 对
    你的 driver 没导进来。。
      

  3.   

    /************
    //classpath=yourClassPath;class12.zip
    //File database.properties 
    jdbc.drivers=oracle.jdbc.driver.OracleDriver
    jdbc.url=jdbc:oracle:thin:@localhost:1521:ouyang
    jdbc.username=scott
    jdbc.password=tiger
    *************/
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    class DatabaseOption
    {
    public static Connection getConnection(String databaseFileName)      
    throws SQLException, IOException
        {  
          Properties props = new Properties();
          FileInputStream in = new FileInputStream(databaseFileName);
          props.load(in);
          in.close();

          String drivers = props.getProperty("jdbc.drivers");
          if (drivers != null){
          try{
             Class.forName(drivers);
          }catch(Exception e)
          {
             e.printStackTrace();
          }
          }
          String url = props.getProperty("jdbc.url");      
          String username = props.getProperty("jdbc.username");
          String password = props.getProperty("jdbc.password");
          
          return
             DriverManager.getConnection(url, username, password);
         }
        
         public static void executeSQL(Connection conn,String insertSqlStr)
          throws SQLException, IOException
         {
          Statement stat = conn.createStatement();
          boolean hasResultSet = stat.execute(insertSqlStr);
            if (hasResultSet)
                   showResultSet(stat);
         }
         
         public static void showResultSet(Statement stat) 
           throws SQLException
        { 
          ResultSet result = stat.getResultSet();
          ResultSetMetaData metaData = result.getMetaData();
          int columnCount = metaData.getColumnCount();

          for (int i = 1; i <= columnCount; i++)
          {  
             if (i > 1) System.out.print(", ");
             System.out.print(metaData.getColumnLabel(i));
          }
          System.out.println();

          while (result.next())
          {  
             for (int i = 1; i <= columnCount; i++)
             {  
                if (i > 1) System.out.print(", ");
                System.out.print(result.getString(i));
             }
             System.out.println();
          }
          result.close();
       }
    }
         
    public class Test
    {
    public static void main(String args[])
    {
    String strCreateTableSQL="create table table_name1(a number(10),b number(10),c number(10),d number(10))";
    String strSQL="insert table_name1(a,b,c,d) values (1,2,3,4)";
    try{
    Connection conn=DatabaseOption.getConnection(args[0]);
    System.out.println("database connect success");
    DatabaseOption.executeSQL(conn,strCreateTableSQL);
    System.out.println("create table success");
    while(true)
    {
    System.out.println("main will sleep 50s to be continued...");
    Thread.sleep(5*10000);
    DatabaseOption.executeSQL(conn,strSQL);
    System.out.println("insert table success");
    }
    }catch(SQLException e)
    {
    e.printStackTrace();
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }
    }
      

  4.   

    我没有找到class12.jar, 只在%Oracle_home%\JDBC\Lib下找到classes12.jar, 你们指的是这个吗?%Java_home%是指什么目录? 我把它指向D:\JBulider7\Jdk1.3.1下, 对吗?JDK1.3.1是在安装完Jbuilder时自动安装的吗?
      

  5.   

    你需要一个.jar Driver 包.需要的话email : [email protected]
      

  6.   

    使用一个Oracle JDBC驱动器建立与127.0.0.1:1521的名为mydatabase的数据库。
    Connection connection=null; 
    try{
    //加载 JDBC 驱动
    String driverName=”oracle.jdbc.driver.OracleDriver”; 
    Class.forName(driverName); 
    String serverName=”127.0.0.1”   //创建连接
    String portNumber=”1521” 
    String sid=”mydatabase”; 
    String url=”jdbc:oracle:thin@”+serverName+”:”+portNumber+”:”+sid; 
    String username=”username”; 
    String password=”password”; 
    Connection=DriverManager.getConnection(url,username,password); 
    }catch(ClassNotFoundException e){ 
    //无法找到数据库驱动
    }catch(SQLException e){ 
    //无法连接到数据库
    }
      

  7.   

    谢 hystudy(何何) 
    同时也谢大家。
    因为分数太少,给的少别见笑。