Home java Connect OJDBC

Connect OJDBC




Can’t connect the driver.
Downloaded file ojdbc8.jar
Pointed to Classpath to the folder in which the file

is located

Perform this code:

import javax.xml.parsers.parserconfigurationexception;
Import java.io.ioException;
Import java.sql.connection;
Import java.sql.drivermanager;
Import java.sql.sqlexception;
Public Class SQLEXAMPLES {
  Public Static Void Main (String Args []) Throws ParserconfigurationException, IoException, SQLEXCEPTION, CLASSNOTFOUNDEXCEPTION {
    String Username = "User";
    String Password = "Pass";
    String ConnectionURL = "JDBC: Oracle: Thin: @ 1521: L10";
    //DriverManager.registerDriver (new oracle.jdbc.oracledriver ());
    Try {
      Class.Forname ("oracle.jdbc.driver.oracledriver");
      Connection Connection = DriverManager.getConnection (ConnectionURL, UserName, Password);
      System.out.PrintLN (Connection);
      System.out.PrintLN ("SSS");

I get errors:

Exception in Thread “Main” java.lang.classNotFoundException:

oracle.jdbc.driver.oracledriver at
java.net.urlclassloader.findclass (urlclassloader.java:381) at
java.lang.classloader.loadclass (classlaader.java:424) at
Sun.Misc.Launcher $ appclassloader.loadclass (launcher.java:34) at
java.lang.classloader.Loadclass (classlaader.java:357) at
java.lang.class.Forname0 (Native Method) at
java.lang.class.Forname (class.java:264) at
Sqlexamples.main (sqlexamples.java:16)

How to check that really the driver is installed correctly and does it work?

Answer 1

  1. In Classpath, you must not specify the folder in which the jar file lies, and directly the jar file itself.
  2. in Idea Add a JAR file to project properties (Project Structure) in Libraries.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions