Issue in connecting Java thin driver in oracle 11G r2
Asked Answered
K

6

5
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

Kamerad answered 2/12, 2012 at 9:0 Comment(0)
L
9

Just solved this issue by using: jdbc:oracle:thin:@//ipadress:portnumber/service_name

Leer answered 31/5, 2016 at 13:27 Comment(1)
It solved to me... specifically the "//" after "@"Budweis
F
4

You are missing SID (or service name) on the end of connection string.

It has to be "host:port:sid"

Furlani answered 2/12, 2012 at 9:8 Comment(1)
Added sid and then it was showing the below error This is what i gave.orcl is my connection name please correct if I am doing wrong "jdbc:oracle:thin:@localhost:1521:orcl" It was showing me the below error after adding SID as orcl java.sql.SQLException: ORA-28000: the account is locked at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289) at oracle.jdbc.ttc7.O3log.receive2nd(O3log.java:496) at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:278) could you please help me in thisKamerad
E
2

it should be

String url=" jdbc:oracle:thin:@Localhost:1521:XE";

Executioner answered 13/1, 2015 at 10:0 Comment(0)
A
1

Add the database SID in your connection string.

String url="jdbc:oracle:thin:@localhost:1521:SID_GOES_HERE";
Avigdor answered 2/12, 2012 at 9:9 Comment(5)
It was showing me the below error after adding SID as orcl This is what i gave.orcl is my connection name please correct if I am doing wrong "jdbc:oracle:thin:@localhost:1521:orcl" java.sql.SQLException: ORA-28000: the account is locked at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289) at oracle.jdbc.ttc7.O3log.receive2nd(O3log.java:496) at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:278) could you please help me in thisKamerad
ALTER USER username ACCOUNT UNLOCK, Also make sure that your user has been granted the correct permissions.Avigdor
No luck I doesnt know about oracle connections and all.Could please help me in this.I am creating local connection in sql developer and in the connection I am changing to Local/Bequeath and creating a database and in this I am creating tables.Is there anything that has to be done rather than thisKamerad
Connect as the sys user in sql developer. You will see "Other Users" expand this. Right click the schema and view properties. Within this dialog should be an option to unlock the user and grant privileges. I do not have sql developer handy so these instructions are not exact.Avigdor
I am able to connect but it says table/view is not there but I created a table with name adobetrail and checkd in sqlplus SQL> select * from tab; TNAME TABTYPE CLUSTERID ------------------------------ ------- ---------- ADOBETRAIL TABLE Below was my console message CONNECTED java.sql.SQLException: ORA-00942: table or view does not exist at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)Kamerad
V
1

And your SID probably is XE, so it should be jdbc:oracle:thin:Localhost:1521:XE

Vernissage answered 2/12, 2012 at 10:56 Comment(0)
P
0

I had the same problem, same error:

java.sql.SQLException: Io exception: Invalid connection string format, a valid format is: "host:port:sid"

I resolved it by updating my JDBC driver. In my particular case, from ojdbc7.jar to to ojdbc8-12.2.0.1.jar

Plessor answered 5/5, 2020 at 20:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.