• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Class.forName("")

 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,
I have to get a connection and do databse operations. I know the following things. but how to make set up to avoid ClassNotFoundException.

code is:

try{
Class c = Class.forName("OracleDriverName");
Connection connection = DriverManager.getConnection("URL","USER","PWD");
System.out.println("helloWorld: = "+c);
}catch(Exception e ){
System.out.println("Exception is = "+e);
}

Here,
Class c = Class.forName("OracleDriverName");

here, where the OracleDriverName is put, and from where we can download the oracle driver.please let me know the URL, where i can download the oracle driver.

Thanks,
Mats.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should bbe the fully qualified name of the Oracle driver, unless you are using Java 6 and Oracle's JDBC 4.0 driver, in which case that line is no longer required (Oh happy days!)

Either way you'll still need the jdbc driver from oracle.com
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would imagine that googling for "download oracle jdbc driver" points you in the right direction.
 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I downloaded the driver and: now problem in getting connection

Class.forName("oracle.jdbc.driver.OracleDriver");//works fine
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@sonny:1521:ORCLADMIN", "SCOTT", "TIGER");

The error is:

Exception is >>>>> ClassNotFoundException = java.sql.SQLException: Io exception:
Connection refused(DESCRIPTION=(TMP=)(VSNNUM=168821762)(ERR=12505)(ERROR_STACK=
(ERROR=(CODE=12505)(EMFI=4))))

what can be the problem for this?

Thanks,
Mats.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think there is nor ClassNotFoundException

your exception is
IOException:
Connection refused(DESCRIPTION=(TMP=)(VSNNUM=168821762)(ERR=12505)(ERROR_STACK=
(ERROR=(CODE=12505)(EMFI=4))))

this means that the oracle server has refused connection.

Cause:
1. Oracle is not started.
2. Credentials are not correct.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Error code 12505 means TNS: listener could not resolve SID given in connection description.
[ September 02, 2008: Message edited by: Rene Larsen ]
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mats,
For me, the best way to learn is to read the documentation.
Have you seen this Web page:

http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html

Good Luck,
Avi.
 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all thank you very much.

now i am getting onother exception :

java.lang.ArrayIndexOutOfBoundsException: 7

I think, this is the problem with downloaded jar file. will post the result after testing.
 
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Highly unlikely that the problem is with the downloaded .jar.
Please post more details of the Exception.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic