应该是找不到这个类吧,或odbc配置错啦

解决方案 »

  1.   

    你的数据库是什么?
    下面是一个例子,这里提供的是一个通过JDBC以TCP/IP方式访问ORACLE数据库的例子,包括直接执行SQL语句和调用存储过程两种方式:import java.sql.*;
    import java.lang.*;
    import java.io.*;public class JDBC_EXAMPLE {
    public static void main(String args[]){
    Connection connection=null;
    Statement dispSTMT=null;    //用于装载执行静态的SQL语句
         CallableStatement callableSTMT=null;
    //可以调用数据库存储过程
         ResultSet result; String sQueryStr="";
    String sVolLevel=""; //建立数据库连接
    try{
       Class.forName("oracle.jdbc.driver.OracleDriver");
       connection = DriverManager.getConnection (
    "jdbc:oracle:thin:@10.136.140.156:1521:mis",
    "UserName","Password"); //数据库的用户名和口令
       //getConnection(String url,String UserName,String UserPassword)
       dispSTMT=connection.createStatement();
        }catch(Exception e){}
        
        //执行SQL语句并去取得数据集
        try {
        sQueryStr="select TO_CHAR(SYSDATE) as SD form DUAL";
          result=dispSTMT.executeQuery(sQueryStr);
          if (result.next())
            sVolLevel=result.getString("SD").trim();
        }catch(Exception e){}
        
        //执行存储过程并取得数据
        try{
          callableSTMT=(CallableStatement)con.prepareCall("{call SP_GETDYHGL(?,?,?,?,?,?,?,?)}");      callableSTMT.clearParameters();

    String sInParm1,sInParm2,sInParm3,sInParm4;
    String sOutParm1,sOutParm2;
    float  fOutParm3,fOutParm4;

    sInParm1 ="Input Parm1";
    sInParm2 ="Input Parm2";
    sInParm3 ="Input Parm3";
    sInParm4 ="Input Parm4";      //输入参数
          callableSTMT.setString(1,sInParm1);
          callableSTMT.setString(2,sInParm2);
          callableSTMT.setString(3,sInParm3);
          callableSTMT.setString(4,sInParm4);      //注册输出参数
          callableSTMT.registerOutParameter(5,Types.VARCHAR);
          callableSTMT.registerOutParameter(6,Types.VARCHAR);
          callableSTMT.registerOutParameter(7,Types.FLOAT);
          callableSTMT.registerOutParameter(8,Types.FLOAT);      //执行存储过程
          callableSTMT.execute();      //取得输出数据
          sOutParm1   =callableSTMT.getString(5);
          sOutParm2 =callableSTMT.getString(6);
          fOutParm3   =callableSTMT.getFloat(7);
          fOutParm4   =callableSTMT.getFloat(8);
          
        }catch(Exception e){}
        
      }  
    }