Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package connection;
- import java.sql.*;
- public class Connection {
- public static void main(String[] args) throws Exception
- {
- Connection con1=null;
- String c="oracle.jdbc.driver.OracleDriver";
- Class.forName(c);
- String url="jdbc:oracle:thin:@LAPTOP-1CQ5FAGB:1521:XE";
- String user="system";
- String passwd="srpnk";
- con1=(Connection) DriverManager.getConnection("jdbc:oracle:thin:@LAPTOP-1CQ5FAGB:1521:XE","system","srpnk");
- System.out.println("connected");
- }
- }
- Exception in thread "main" java.lang.ClassCastException: oracle.jdbc.driver.T4CConnection cannot be cast to connection.Connection
- at connection.Connection.main(Connection.java:17)
- C:UsersNandhiniAppDataLocalNetBeansCache8.2executor-snippetsrun.xml:53: Java returned: 1
- BUILD FAILED (total time: 0 seconds)
- public class Connection { // <-- This is a bad idea
- public static void main(String[] args) throws Exception
- {
- Connection con1=null;
- // ...
- con1=(Connection) DriverManager.getConnection("jdbc:oracle:thin:@LAPTOP-1CQ5FAGB:1521:XE","system","srpnk");
- System.out.println("connected");
- }
Add Comment
Please, Sign In to add comment