利用Java程序连接Linux系统上的Oracle数据库,如何对环境进行配置?

解决方案 »

  1.   

    使用jdbc连接,不需要在服务器端进行设置。
      

  2.   

    我的程序如下:
    import java.sql.*;public class WITableData {
        private final String oracleDriverName = "oracle.jdbc.driver.OracleDriver";
        private final String oracleUrlToConnect ="jdbc:oracle:thin:@1.1.1.1:1521:AS7"; 
        private Connection myConnection = null;
        
        public WITableData()
        {
            try
            {
                Class.forName(oracleDriverName);
            }
            catch(ClassNotFoundException ex)
            {
                System.out.println(getErrorMessage(ex,"The Driver loaded error,please contact to your Software Designer!").toString());
            }
        }
        
        public StringBuffer getErrorMessage(Exception ex,String alarmMessage)
        {
            StringBuffer errorStringBuffer = new StringBuffer();
            errorStringBuffer.append(alarmMessage);
            errorStringBuffer.append(ex.getMessage());
            return errorStringBuffer;
        }
        
        /**
         * getConnection method 
         * @return Connection
         */
        public Connection getConnection()
        {
            try
            {
                this.myConnection = DriverManager.getConnection(oracleUrlToConnect,"1","1");
                System.out.print("connection successfully");
            }
            catch(Exception ex)
            {
                System.out.println(getErrorMessage(ex,"Can not get connection,please contact to your Software Designer!").toString());
            }
            
            return this.myConnection;
            
        }
        
        /**
         * @param args
         */
        public static void main(String[] args) {
         WITableData wi = new WITableData();
            try
            {
                Connection myConnection = wi.getConnection();
                System.out.println("Now begin to excute.............");            
            }
            catch(Exception ex)
            {
                System.out.println(wi.getErrorMessage(ex,"Application error,please contact to your Software Designer!").toString());
            }
        }
    }运行以后,总是报异常,所以我想问问是不是我的客户端环境配置的问题? 
      

  3.   

    异常:The Driver loaded error,please contact to your Software Designeroracle.jdbc.driver.OracleDriver Can not get connection,please contact to your Software Designer!No suitable driverNow begin to excute.............
      

  4.   

    自己写的代码都不知道是干嘛用的?
    说明你还没有吃透JDBC的基本原理。
    Class.forName(oracleDriverName)会在JVM加载对应Driver的字节码。抛出的异常说明是找不到对应的字节码文件。
    现在知道要干什么了吧?
    你不要说不会配claspath吧...
      

  5.   

    我追加了啊,在classpath里将classes12dms_g.jar已经追加进去了
      

  6.   

    需要配一个classpath
    另外jdk 1.6都出来了能不能别用 classes12.jar了。
      

  7.   

    我已经搞定了,将ojdbc加到eclipse项目中。谢谢几位,分数送上