Javatpoint Logo

Exception in thread "main" java.sql.SQLException: Socket read timed out

By: tapan6*** On: Fri Oct 05 18:52:04 IST 2012     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank Profile
// SelectTest.java

import java.sql.*;


public class SelectTest
{
public static void main(String args[]) throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
if (con == null)
{
System.out.println("Con not established..");
}
else
System.out.println("Conn established...");
}
}

Exception

e:\JavaPrgms\JDBC>javac SelectTest.java

e:\JavaPrgms\JDBC>java SelectTest
SelectTest main(-)
Driver class loaded
Exception in thread "main" java.sql.SQLException: Socket read timed out
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(T4CDriverExtensio
n.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 SelectTest.main(SelectTest.java:13)
Caused by: oracle.net.ns.NetException: Socket read timed out
at oracle.net.ns.Packet.receive(Packet.java:320)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:286)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)
... 7 more

e:\JavaPrgms\JDBC>


So , Here i am using Windows7 64bit , Oracle 11g Releases 2 64bit version,

I tried same example with MySql database its working properly but here the socket is continuously reading and timeout exception is rised after 5 mins.. so how can i remove this exception ,?
i checked my port no in tnslistener.ora its "1521" and my sid is :"orcl" where the problem is ?
Up0Down

 
set classpath=ojdbc14.jar or classes12.jar......whatever it may be check(what jar file available in your oracle s/w) and then again compile and run it will be working.....
Image Created0Down

By: [email protected] On: Sat Oct 13 10:59:12 IST 2012 Question Reputation0 Answer Reputation20 Belt Series Points0 20User Image
Are You Satisfied :0Yes1No