• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception in thread "main" java.sql.SQLException: No suitable driver

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to Java concepts. When i am trying to establish JDBC conncetion with Oraqcle 9i i am getting the below error:

Can any one of you sugust me solution for this:

Exception in thread "main" java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at JDBC1.main(JDBC1.java:13)

This is the syntax i am using to connect. Please help me out::

Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:odbc:thin:@localhost:1521","scott","tiger");

Thanks in Advance.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Poornima,
Welcome to the ranch. We are happy to have you here

As you have seen, we have quite a lot of forums. If you post on the proper forum you can get the most out of the ranch.
Moving this to an appropriate forum.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the required .jar file in your classpath?
 
Rosy Mary
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. I have the following located in my class path:

C:\oracle\ora92\jdbc\lib\classes12.zip;

Please let me know what needs to be done.

Thanks in Advance.
 
Rosy Mary
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What should be the .Jar file used to be placed in the class path?

Thanks.
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
con=DriverManager.getConnection("jdbc:odbc:thin:@localhost:1521:xxxx","scott","tiger");

I think you have missed the database name. Replace the database name with xxxx


[edit]Disable smilies. CR[/edit]
 
Rosy Mary
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya i have tried that option too but no use still the error persists.. Any other cause for this error??

Thanks.
 
Sujai Kaarthik
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you imported the corresponding package?
Because, I have did that fault many times
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Poornima Yeleswarapu wrote:Thanks for your reply. I have the following located in my class path:

C:\oracle\ora92\jdbc\lib\classes12.zip;

Please let me know what needs to be done.



classes12.jar is for JDK 1.2 and 1.3 according to the oracle. Which JDK version you are using? You have to download the appropriate driver from there and place it in the classpath, then try it.
 
Sujai Kaarthik
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Oracle, try thiS:

Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:yyyy","scott","tiger");
 
Rosy Mary
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The java veriosn i am using is "1.5.0_06". And i have imported the required package import java.sql.*;
I thing i am using the correct syntax to get the veriosn?
I have used java -version to get this. Correct me if i am wrong......
 
Sujai Kaarthik
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exception in thread "main" java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at JDBC1.main(JDBC1.java:13)


I think this error will popup only when there is an error in the parameters you pass in the getConnection(...)
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Poornima Yeleswarapu wrote:
I thing i am using the correct syntax to get the veriosn?
I have used java -version to get this. Correct me if i am wrong......



Yes, That's right.
Have you go through the link I gave above. I haven't tried this but you better use the appropriate driver implementation to suit your JDK version and check the documentation for the correct class name and the URL

 
Rosy Mary
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Might be but i am not sure if there is any mistake in the syntax of that... Anyways need to try again...

Thanks in Advacne.
 
Sujai Kaarthik
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just try replacing "odbc" with "oracle" and see whether it works or not.
I also use Oracle as my backend and I use to specify like this:

con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:yyyy","scott","tiger");

and not

con=DriverManager.getConnection("jdbc:odbc:thin:@localhost:1521:yyyy","scott","tiger");
 
Sujai Kaarthik
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Poornima Yeleswarapu wrote:Might be but i am not sure if there is any mistake in the syntax of that... Anyways need to try again...

Thanks in Advacne.



there is no syntax error, but there might be wrong parameters

though I am not sure about it
 
Rosy Mary
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya tried using the above syntax and i now encounter this error: do not know what this means.....
since i am using Oracle......


con=DriverManager.getConnection("jdbcracle:thin:@localhost:1521:yyyy","scott","tiger");

java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNU
M=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
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.<init>(OracleConnection.java:404)

at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at OraThin.main(OraThin.java:9)
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like something which would sit better on our JDBC forum . . . moving
 
Sujai Kaarthik
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

con=DriverManager.getConnection("jdbcracle:thin:@localhost:1521:yyyy","scott","tiger");



its not jdbcracle. the smiley took the colon-":" and "o"!!

its "jdbc: oracle:thin:@localhost:1521:yyyy" , where YYYY is your database name.

remove the space between : and oracle

I just altered my code in an application as your's code. It shows the same error. The above solution should solve your problem
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I'm having much the same problem. I'm new to using JDBC so I've tried going through the same steps to resolve the issue but with no luck. Please help.

I'm using Eclipse and JDeveloper (having same problem in both environments) in Windows 7.

This is the entirety of my environment variable "CLASSPATH = c:\oracle\sqldeveloper\jdbc\ojdbc6.jar". Should there be more?

My code is as follows:

import java.sql.*;

public class ptSQL {

public static void main(String args[]) throws ClassNotFoundException, SQLException{
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=devel-ora-db1.bdainc.bda)(PORT=1521))" +
"(PROTOCOL=tcp)(CONNECT_DATA=(SERVICE_NAME=EBSDEVL)(INSTANCE_NAME=EBSDEVL)))",
someuserid,
somepassword);
conn.close();
}

}

Very basic, I just want to see if I can open the connection. Once I get to that point the rest will be easy.

thanks in advance.

 
Greenhorn
Posts: 14
IntelliJ IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George,

Can you try the simple one connection String like ,



Please don't forget to replace the xxxx=Your Schema name.

Make sure that your TNSListener service Of Oracle Database Server is running.

Thanks and Regards
Nirav Joshi

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say you have "the same problem", that's a bit confusing because there were at least two different problems discussed in the thread you grabbed onto. Could you spare a minute and provide a description of your problem?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guys, i have no issues with the drivers..but having some problems related to the url connection...i would like to know what after the port number should be specified..and also which username and password should i use:as i use different (username and password) at sql command prompt and system as username and **** as password at the oracle homepage..
thanks in advance!!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have tried to run this program..but failed due to the exception i.e. java.sql.SQLException: could not resolve the connect identifier specified

can you please help me regarding this problem .


import java.sql.*;

class Ex_Type1_Oracle_Update
{
public static void main(String args[])throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:oci:@XE","adv11am","adv11am");
Statement st=con.createStatement();
int count= st.executeUpdate("Update doctor2 set dsal=dsal+200 where did=1");
System.out.println(count+"record/s updated successfully");
con.commit();
st.close();
con.close();
}}
 
reply
    Bookmark Topic Watch Topic
  • New Topic