java代码连接Oracle数据库出错,求解,以下是错误信息
import java.sql.*;public class Test {
public static final String DBDRIVER = "oracle.jdbc.driver.OracleDriver" ;
public static final String DBURL = "jdbc:oracle:thin:@localhost:1158:mldn" ;
public static final String DBUSER = "scott" ;
public static final String DBPASS = "tiger" ;
public static void main(String[] args) {
Connection conn = getConnection();
if (conn != null) {
System.out.println("success!");
} else {
System.out.println("error!");
}
}
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName(DBDRIVER);
} catch (ClassNotFoundException e) {
// e.printStackTrace();
}
try {
conn = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}
java.sql.SQLException: Got minus one from a read call
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at Test.getConnection(Test.java:28)
at Test.main(Test.java:10)
Caused by: Got minus one from a read call
at (Packet.java:285)
at (NSProtocol.java:286)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)
... 8 more
error!