import java.sql.*;public class testJDBC {

public static void main(String[] args) throws Exception {
Class.forName("oracle.jdbc.driver.OracleDriver");
//new oracle.jdbc.driver.OracleDriver();
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.101:1521:orcl","scott","890415");
Statement stmt = conn.createStatement();
ResultSet re = stmt.executeQuery("select * from user_col_comments");
while (re.next()){
System.out.println(re.getString("TABLE_NAME"));
}
re.close();
stmt.close();
conn.close();
}
}
ps:在命令行下能用scott登陆 scott为dba权限
请问是什么原因

解决方案 »

  1.   

    你的是10g吧?
    在默认情况下 scott是锁定的
    用system as dba登录
    执行下面的语句
    alter user scott account unlock;
      

  2.   

     我用的是11g 
     开始的时候 scott是锁定的
     但解锁之后就出现了invalid username/password; logon deni的情况。
      

  3.   

    你确定在sqlplus中Scott账户可以登录吗?解锁还要指定密码的。
      

  4.   

    我确定在sqlplus中scott可以登录 
    我解锁用的是sys账号 没有要密码
      

  5.   

    那估计是密码不对?
    你在sqlplus里是怎么登录的?
      

  6.   

    可能因为的密码为数字开头的缘故、你可以修改试一下
    DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.101:1521:orcl","scott","\"890415\"");
      

  7.   

    谢谢大家
    在sqlplus中 sqlplus scott/890415 as sysdba改成六楼这样还是不行。。还是报ORA-01017: invalid username/password; logon denied