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;
}
连接名称:orcl 用户名:scott 密码:tiger 连接详细信息:scott@
我正在使用 Oracle g11 第 2 版,并且我已经在构建路径中包含了 ojdbc.jar。尝试建立连接时,出现以下堆栈跟踪错误:
java.sql.SQLException: Io 异常:连接字符串格式无效,有效格式为:oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess 的“host:port:sid”。在 oracle.jdbc.driver.OracleConnection.(OracleConnection.java:404) 的 oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333) 在 oracle.jdbc.driver 的 DBError.throwSqlException(DBError.java:179)。 OracleDriver.getConnectionInstance(OracleDriver.java:468) 在 oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314) 在 java.sql.DriverManager.getConnection(Unknown Source) 在 java.sql.DriverManager.getConnection(Unknown Source ) 在 com.adobe.daoimpl.DBimplementation.registration(DBimplementation.java:21) 在 com.adobe.com.adobe.util.DBConnection$DBUtil.getConnection(DBConnection.java:23)。service.AdobeService.registration(AdobeService.java:13) 在 webservice.Web.service(Web.java:16) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 在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) 在 org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) 在 org.apache.axis.strategies.InvocationStrategy.visit (InvocationStrategy.java:32) 在 org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) 在 org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) 在 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) 在 javax.servlet.http.HttpServlet 在 org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:647) .service(HttpServlet.java:728) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)AxisServletBase.service(AxisServletBase.java:327) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)AxisServletBase.service(AxisServletBase.java:327) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
提前致谢