Java

Moderators: zibadian
Number of threads: 7818
Number of posts: 18218

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
jdbc drivers loading but connection not establishing Posted by papu_c on 14 May 2005 at 6:06 AM
import java.sql.*;
import java.io.*;

class testcon
{
public static void main(String a[]) throws Exception
{
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver loaded");
} catch (ClassNotFoundException e) {

System.out.println("Driver not loaded");
e.printStackTrace();

}

try
{
String url = "jdbc:oracle:thin:@localhost:1521:????";
Connection myConnection = DriverManager.getConnection(url, "scott", "tiger");
System.out.println("Connected");
}
catch(Exception e)
{System.out.println("Connection not established");
e.printStackTrace();}

}
}

what should i put in '???' place in string url
from where shall i get that name?





Report
Re: jdbc drivers loading but connection not establishing Posted by manuph on 16 May 2005 at 4:51 AM
: import java.sql.*;
: import java.io.*;
:
: class testcon
: {
: public static void main(String a[]) throws Exception
: {
: try {
: Class.forName ("oracle.jdbc.driver.OracleDriver");
: System.out.println("Driver loaded");
: } catch (ClassNotFoundException e) {
:
: System.out.println("Driver not loaded");
: e.printStackTrace();
:
: }
:
: try
: {
: String url = "jdbc:oracle:thin:@localhost:1521:????";
: Connection myConnection = DriverManager.getConnection(url, "scott", "tiger");
: System.out.println("Connected");
: }
: catch(Exception e)
: {System.out.println("Connection not established");
: e.printStackTrace();}
:
: }
: }
:
: what should i put in '???' place in string url
: from where shall i get that name?
:
: Generally 'orcl' will be exist but if have changed the service name while installing oracle then we need to specify that name.
:
:
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.