Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:54:46+00:00 2026-05-27T06:54:46+00:00

In jdbc type 4 connection driver has been registered but connection has some error

  • 0

In jdbc type 4 connection “driver” has been registered but connection has some error i.e.

Connection con=DriverManager.getConnection("jdbc:oracle:@localhost:1521:XE","system","manager");

error: -incompatible types,found:- java.sql.connection, required :Connection

import java.sql.*;
class A
{
    public static void main(String args[])
    {
        try
        {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","manager");
            Statement stmt= con.createStatement();
            ResultSet rset=stmt.executeQuery("Select * from emp");
            while(rset.next())
            {                               
            System.out.println(rset.getInt(1)+"\t"+rset.getString(2)+"\t"+rset.getString(3)+"\t"+ rset.getFloat (4));
            }
            con.close();
        }
        catch(Exception e)
        {
            System.out.println(e);  
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:54:46+00:00Added an answer on May 27, 2026 at 6:54 am

    If I understood correctly, this error message is a compiler error message. It means that your code is in the default package, and you have a class in this default package which is named Connection. DriverManager.getConnection(...) returns a java.sql.Connection. Use

    java.sql.Connection con = DriverManager.getConnection(...)
    

    or rename your own Connection class to something else.

    And don’t ever use the default package. It leads to all sorts of problems and should be avoided. Always put your classes in a package of yours.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed that JDBC has different Drivers like: Type 1 Driver Type 2 Driver
Oracle JDBC connection with Weblogic 10 datasource mapping, giving problem java.sql.SQLException: Closed Connection I
[1] In JDBC, why should we first load drivers using Class.forName(some driver name). Why
I know this has been asked before, but it just doesn't work for me.
I have setup the JDBC connection pooling and its showing the following error when
Will Oracle PreparedStatement.executeUpdate() API throw an exception of type SQLException if the connection pool
I'm getting the following excpetion: java.sql.SQLException: Protocol violation at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:190) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:286)
The JDBC 3.0 spec talks about Connection (and Prepared Statement) pooling. We have several
currently i have jdbc code with the following basic stucture: get Connection (do the
I am getting JDBC error when I attempt a commit through hibernate to SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.