Hi I'm practicing Java oracle database connection with Eclipse.
Below is my code:
package connection;
import java.sql.* ; // for standard JDBC programs
import java.math.* ; //
public class Connection {
public static void main(String[] args) throws SQLException {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver class!");
System.exit(1);
}
String URL = "jdbc:oracle:thin:C##AVIVI/avivi9694@localhost:1521:oracleavivi";
Connection conn = (Connection) DriverManager.getConnection(URL);
Below is the "ERROR":
Exception in thread "main" java.lang.ClassCastException: oracle.jdbc.driver.T4CConnection cannot be cast to connection.Connection
at connection.Connection.main(Connection.java:18)
I imported all the "jar" file from "jre7'-"lib"folder into my project(I'm a newbie,so didnt quite sure which jar I need so I imported them all,don't know if this will affect the connection or not)