Reputation: 24721
I am developing a Java EE project. I have included ojdbc14.JAR from here in my projects WebContent/WEB-INF/lib
Code I have written:
Connection conn = null;
String driverName = "oracle.jdbc.OracleDriver";
String url = "jdbc:oracle:thin:@//127.0.0.1:8080/apex";
Class.forName(driverName);
conn = DriverManager.getConnection(url, "system", "mahesh");
The runtime exception I get is:
java.sql.SQLException: Io exception: Got minus one from a read call
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:420)
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(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.obos.utility.ConnectionManager.main(ConnectionManager.java:26)
from last line the exception occurs at DriverManager.getConnection()
I suspect the problem is in connection string since I am able to login with username and password through SQL Command Line utility. But I am not able to rectify it.
I have used "jdbc:oracle:thin:@//127.0.0.1:8080/apex" since I am getting database manager in browser at following address:
However I have also tried "jdbc:oracle:thin:@//127.0.0.1:8080", but no use. Please help.
I am running Windows 8 x64.
Upvotes: 0
Views: 1928
Reputation: 11
You did the same mistake as I did
the connection string should be
String url = jdbc:oracle:thin:@127.0.0.1:1521:XE
Upvotes: 1
Reputation: 691755
8080 is the port of the web server hosting the webapp allowing to access the database. The database itself doesn't listen on this port. AFAIR, the default port of Oracle database is 1521. Read http://docs.oracle.com/cd/B25329_01/doc/appdev.102/b25320/getconn.htm for more information.
Upvotes: 2