I am very new with Oracle, I have installed 11g 64 bit on my Windows 10. And only started the oracle database using emctl start dbconsole
. I have the following code to be connected to my database, which results in the shown exception. I have investigated a lot about this issue on web/stackoverflow/youtube etc, and could not find a straightforward working procedure, would you What is the problem? Please note that the exception happens at the following line:
con = DriverManager.getConnection(url, props);
The code looks like:
String url = "jdbc:oracle:thin:@localhost:1158:searchengine";
//properties for creating connection to Oracle database
Properties props = new Properties();
props.setProperty("user", "sys");
props.setProperty("password", "1234");
//creating connection to Oracle database using JDBC
try
{
//Class.forName("oracle.jdbc.OracleDriver");
con = DriverManager.getConnection(url, props);
//con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1158:searchengine", "system", "1234");
String query = "alter session set nls_calendar='Persian'";
PreparedStatement pr = con.prepareStatement(query);
pr.execute();
query = "select sysdate from dual";
pr = con.prepareStatement(query);
ResultSet res = pr.executeQuery();
while (res.next())
{
System.out.println(res.toString());
}
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
java.sql.SQLRecoverableException: IO Error: Got minus one from a read call
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at Controllers.DBController.connect(DBController.java:24)
at Wrapper.TestMain.start(TestMain.java:21)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
Caused by: oracle.net.ns.NetException: Got minus one from a read call
at oracle.net.ns.Packet.receive(Packet.java:311)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:300)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)