Topic: 这又是什么错啊,弄了几天了.

  Print this page

1.这又是什么错啊,弄了几天了. Copy to clipboard
Posted by: justforu
Posted on: 2005-04-12 11:29

我的代码:
import java.io.*;
import java.sql.*;
class OdbcConn
{
  public static void main(String args[])
  {
    try
    {
      Class.forName( "oracle.jdbc.driver.OracleDriver" );
    }
    catch(ClassNotFoundException ce)
    {
      System.out.println("SQLException1"+ce.getMessage());
    }
    try
    {
      Connection con=DriverManager.getConnection( "jdbc:oracle:thin:@130.1.2.1:1521:to97sale", usys6, usys6 );
      Statement stmt=con.createStatement();
      stmt.close();
      con.close();
    }
    catch(SQLException e)
    {
      System.out.println("SQLException2:"+e.getMessage());
    }
  }
}

编译时报错为:

2.Re:这又是什么错啊,弄了几天了. [Re: justforu] Copy to clipboard
Posted by: bluepure
Posted on: 2005-04-12 12:58

变量没有定义,不会是在记事本写代码的吧?????

-->

Connection con=DriverManager.getConnection( "jdbc:oracle:thin130.1.2.1:1521:to97sale", "usys6", "usys6" );

3.Re:这又是什么错啊,弄了几天了. [Re: justforu] Copy to clipboard
Posted by: justforu
Posted on: 2005-04-12 14:34

对呀,我是在ultraedit里写的.
现在改成这样还是报错,好像是驱动程序的问题,请帮忙看看,应该怎么做啊.
import java.io.*;
import java.sql.*;
class OdbcConn
{
  public static void main(String args[])
  {
    try
    {
      Class.forName( "oracle.jdbc.driver.OracleDriver" );
    }
    catch(ClassNotFoundException ce)
    {
      System.out.println("SQLException1"+ce.getMessage());
    }
    try
    {
      Connection con=DriverManager.getConnection( "jdbc:oracle:thin:@130.1.2.1:1521:to97sale", "usys6", "usys6" );
      Statement stmt=con.createStatement();
      stmt.close();
      con.close();
    }
    catch(SQLException e)
    {
      System.out.println("SQLException2:"+e.getMessage());
    }
  }
}


4.Re:这又是什么错啊,弄了几天了. [Re: justforu] Copy to clipboard
Posted by: why
Posted on: 2005-04-12 18:36

Are you sure you have the Oracle jar in the classpath?
Are you sure the connection URL string is correct?

5.Re:这又是什么错啊,弄了几天了. [Re: justforu] Copy to clipboard
Posted by: justforu
Posted on: 2005-04-13 09:32

我用的是在sun网上下的ojdbc14.jar,classes12.jar放在C:\j2sdk1.4.2\lib目录,classpath里也添加了,我不知道对不对,如果不对请贴一个URL吧

6.Re:这又是什么错啊,弄了几天了. [Re: justforu] Copy to clipboard
Posted by: justforu
Posted on: 2005-04-13 09:39

今天又编译了一次,报错不一样了.

7.Re:这又是什么错啊,弄了几天了. [Re: justforu] Copy to clipboard
Posted by: justforu
Posted on: 2005-04-13 10:05

呵呵,今天早上状态神勇,终于弄出来了,原来是"jdbc:oracle:thinAngry130.1.2.1:1521:to97sale"填错了,最后一个字段我填成数据库名了,应该填SID才对,另外oracle的驱动用ojdbc14.jar就行了.
感谢各位这几天的支持,劳烦各位了.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923