JDBC连接数据库Oracle,连接字符串的问题
Exceptioninthread"main"java.sql.SQLException:无法从套接字读取更多的数据atoracle.jdbc.driver.Databa...
Exception in thread "main" java.sql.SQLException: 无法从套接字读取更多的数据 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:208) at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1118) at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1070) at oracle.jdbc.driver.T4C8TTIpro.receive(T4C8TTIpro.java:131) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:867) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:268) at oracle.jdbc.driver.PhysicalConnection. (PhysicalConnection.java:414) at oracle.jdbc.driver.T4CConnection. (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 TestJDBC.main(TestJDBC.java:24) import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class TestJDBC { public static void main(String[] args) throws ClassNotFoundException, SQLException { String sql = "select * from test"; Class.forName("oracle.jdbc.driver.OracleDriver"); //加载驱动程序 DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());//实例化驱动程序类 String url = "jdbc:oracle:thin:@localhost:1521:PLSExtProc";//驱动程序名:@主机名/IP:端口号:数据库实例名 String userName = "system"; String passWord = "hjl900817"; Connection conn = DriverManager.getConnection(url, userName, passWord); Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery(sql); while (rs.next()) { String a=rs.getString(3); System.out.print(a+"/t"); System.out.println( rs.getDate(5).toString()); } } }
展开
2个回答
展开全部
思路如下:
第一:localhost,换成ip试试?有些机器的确认不出localhost,需要去修改本地域名配置文件
第二:oracle驱动有问题?。。。
第一:localhost,换成ip试试?有些机器的确认不出localhost,需要去修改本地域名配置文件
第二:oracle驱动有问题?。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询