java.sql.SQLException: I/O例外です。: Software caused connection abort: recv failed
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:439)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at test.DB.<init>(DB.java:16)
at test.DB.main(DB.java:23)
源码是:
package test;
import java.sql.Connection;
import java.sql.DriverManager;
public class DB {
Connection conn;
public Connection getConn() {
return conn;
}
public DB(){
String driver="oracle.jdbc.driver.OracleDriver";
String url="jdbc:oracle:thin:@127.0.0.1:1105:orcl";
try {
Class.forName(driver);
conn=DriverManager.getConnection(url,"testchen","testchen");
System.out.println(conn);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new DB();
}
}
就一个连接数据库 使用的是ojdbc14.jar oracle11g
这个是我在别的地方copy过来的,我的代码在内网,和这个差不多
String url="jdbc:oracle:thin:@127.0.0.1:1521:orcl"; 换下端口试试本回答被提问者采纳