DriverManager.getConnection出错(20分)

  • 主题发起人 主题发起人 hongsen
  • 开始时间 开始时间
H

hongsen

Unregistered / Unconfirmed
GUEST, unregistred user!
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:scss")
java.sql.SQLException: 调用中无效的参数
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:183)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:346)
 
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:scss")
参数个数不对,需要写用户名和密码
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:scss","username","password")
 
java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
注册了数据库驱动没有?
to only you:
在java.sql.DriverManager有这个函数
static ConnectiongetConnection(String url) Attempts to establish a connection to the given database URL.
 
to clever_boy_2000
谢谢!可是ConnectiongetConnection(String url) 是把用户名和密码写到url中的
象DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:scss;user=asdfasdf;password=asdfasf")
 
only you:同意你
 
thanks a lot
 
后退
顶部