public static Connection getConnection()throws SQLException,ClassNotFoundException
{ String username="scott";
String password="tiger";
String url="jdbc:oracle:thin:@localhost:1521";
Connection connection = null;
System.out.println("before class");
Class.forName("oracle.jdbc.OracleDriver");
System.out.println("Before connection");
connection=DriverManager.getConnection(url,username,password);
System.out.println("CONNECTED");
return connection;
}
Connection Name: orcl UserName:scott Password:tiger connection details:scott@
I am using Oracle g11 Release 2 and I already included the ojdbc.jar in my build path. When trying to establish the connection, I get the following stack trace error:
java.sql.SQLException: Io exception: Invalid connection string format, a valid format is: "host:port:sid" at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333) at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:404) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.adobe.util.DBConnection$DBUtil.getConnection(DBConnection.java:23) at com.adobe.daoimpl.DBimplementation.registration(DBimplementation.java:21) at com.adobe.service.AdobeService.registration(AdobeService.java:13) at webservice.Web.service(Web.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397) at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186) at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454) at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281) at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
Thanks in advance
Just solved this issue by using: jdbc:oracle:thin:@//ipadress:portnumber/service_name