Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
| Search | Today's Posts | Mark Forums Read
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2004, 02:10 PM
Registered User
 
Join Date: Jul 2004
Location: Locust Grove, OK, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default java.sql.SQLException: Error loading JDBC Driver

classpath =
C:\WINNT\system32;
C:\j2sdk1.4.2_05\lib;
C:\j2sdk1.4.2_05\jre\lib;
C:\oracle\ora92\jdbc\lib\classes111.jar;
C:\oracle\ora92\jdbc\lib\classes12.jar;.

///start of code

import java.sql.*;
import java.util.*;
import oracle.jdbc.*;

public class OracleConnection {

  /*
   ** +----------------------------------------+
   ** | Return a JDBC connection appropiately |
   ** | either inside or outside the database. |
   ** +----------------------------------------+
  */
  public static Connection getConnection() throws SQLException {

    String username = "****";
    String password = "****";
    String driver_class = "oracle.jdbc.OracleDriver";

    // +-------------------------------------------------+
    // | You can use either of the two URLs to obtain a |
    // | default connection. |
    // | "jdbc:default:connection:" |
    // | "jdbc:oracle:kprb:" |
    // +-------------------------------------------------+
    //String defaultConn = "jdbc:default:connection:";
    String thinConn = "jdbc:oracle:thin:@host:port:db";

    Connection conn = null;

    try {

      System.out.print("Loading JDBC Driver -> " + driver_class + "\n");
      Class.forName (driver_class);
      System.out.print("Connecting to -> " + thinConn + ", " + username + ", " + password + "\n");
      conn = DriverManager.getConnection(thinConn, username, password);
      conn.setAutoCommit(false);
      return conn;

    } catch (Exception e) {
      throw new SQLException("Error loading JDBC Driver");
    }

  } // METHOD: (getConnection)

  /*
   ** +--------------------------------------------------------+
   ** | Method to determine if we are running in the database. |
   ** | If oracle.server.version is not null, we are running |
   ** | in the database. |
   ** +--------------------------------------------------------+
  */
  public static boolean connectedToDatabase() {

    String version = System.getProperty("oracle.server.version");
    return (version != null && !version.equals(""));

  } // METHOD: (connectedToDatabase)

} // CLASS: (OracleConnection)


jdphjp
 
Old August 5th, 2004, 12:46 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

String driver_class = "oracle.jdbc.OracleDriver"; initilize to ===>> "oracle.jdbc.driver.OracleDriver"

Remvoe from the classpath option C:\oracle\ora92\jdbc\lib\classes111.jar; if you use <1.4 ver. otherwise remove class12.jar use either one of these

check wether the values are replaced to the connection url
System.out.print("Connecting to -> " + thinConn + ", " + username + ", " + password + "\n");

if not try with host & port no. entering physically once.
U can find the host & port no in D:\oracle\ora92\network\ADMIN\TnsNames.Ora








Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server 2000 Driver for JDBC Errors cash Java Databases 2 December 22nd, 2006 01:18 AM
Exception while loading JDBC driver dshashi1234 Java Databases 0 December 21st, 2006 02:34 AM
java.sql.SQLException: [Microsoft][ODBC Driver Man pvsharinath@gmail.com Java Databases 1 May 5th, 2005 02:40 AM
Cannot load JDBC driver class with com.mysql.jdbc. dzis Apache Tomcat 0 January 29th, 2004 11:57 AM
Cannot load JDBC driver class with com.mysql.jdbc. dzis MySQL 0 January 29th, 2004 11:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.