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

  • Home
  • SEARCH
  • 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 8756451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:05:13+00:00 2026-06-13T14:05:13+00:00

why every time, everyone import (or this is not import) Class.forName(com.mysql.jdbc.Driver).newInstance(); And when I

  • 0

why every time, everyone import (or this is not import)

Class.forName("com.mysql.jdbc.Driver").newInstance();

And when I

import com.mysql.jdbc.Driver;

It display Notice

he import com.mysql.jdbc.Driver is never used

What is the different between this two ??

  • 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-06-13T14:05:14+00:00Added an answer on June 13, 2026 at 2:05 pm

    When you do not actually know which class has to be loaded you go for factory methods.
    In your case it is Class.forName on a database driver class.
    It is a runtime instruction to the JVM to load the class and hence the import ... statement is not required in this case.

    Where as if you use import ... a specific class, the Java compiler tries to find and load it before using it in the class being compiled. In your example case, when you import a class and never use it in your code, usually the IDE’s like MyEclipse where you are writing the code, you will be notified that the imported class never used. It is not an error or warning but you can safely remove to reduce load on compiler.

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

Sidebar

Related Questions

Every time i reset & seed my database it wipes out the standard admin@example.com
Every time I try to access my localhost/phpmyadmin it gives me this error --->
//This is the function that will run every time a new item is added
Hello Everyone, I have made so many Flash presentations, but every time i stuck
Hello everyone I would have a value for the need to save every time
Every time this situation pops up, which is about once every few months, I
Possible Duplicate: how to provide a swap function for my class? Every time I
This is something i seeem to get a different answer for, every time i
Every time when I'm trying to load the .dll in my application, I'm getting
every time I open my Solution in Visual Studio it tries to communicate and

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.