在myeclipse中写入查询oracle数据库中的程序,url,username,passwors都没问题的,但是连接不上 。

爆出的错误是
invalid username/password; logon denied
但是我的用户名和密码在登陆PL/SQL的时候没有问题,电脑中所有的oracle服务均启动成功。
下面是我的程序

package JDBC;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCdemo {
public static void main(String[] args) {
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try {
try {
Class.forName("oracle.jdbc.OracleDriver");
con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:ORCL", "scott",
"maozhenjiayou");
stmt=con.createStatement();
String sql="select name,gender,borndate from employees";
rs=stmt.executeQuery(sql);
System.out.println("姓名"+" "+" 性别"+" "+"日期");
while(rs.next()){
String name=rs.getString("name");
String gender=rs.getString("gender");
rs.getDate("borndate");
System.out.println(name+" "+"gender"+" "+" "+rs.getDate("borndate"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
rs.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}

求大神帮助!!

报的异常就是用户名密码不正确呀
建议
1 新建个用户试试
2 启动监听
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-07-03
用户名和密码不正确,或者,用户被停用了。
建议,先用数据库的客户端工具连接数据库试试。
看能不能连接。
相似回答