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 6336339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:02:16+00:00 2026-05-24T19:02:16+00:00

While writing an application that interacts with a database the only way I can

  • 0

While writing an application that interacts with a database the only way I can get it to work is if I write Class.forName("com.mysql.jdbc.Driver") in every method that interacts with the database.

Is this the only way to do it or is there a simpler way?

  • 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-24T19:02:18+00:00Added an answer on May 24, 2026 at 7:02 pm

    This line can’t possibly work. jdbc:mysql://localhost/phone_book is not a valid class name. You’ll aways get an exception when executing this method.

    If you mean Class.forname("com.mysql.jdbc.Driver"), all it does is make sure the classloader loads the class. When the class is loaded, its static block is executed, and this static block registers the MySQL driver to the JDBC API. Doing it once is sufficient. Once a class is loaded, it’s loaded. Loading it a second time won’t change anything.

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

Sidebar

Related Questions

While writing yet another class full of methods that access database tables to work,
I'm writing a depsktop application (in Java) that interacts with a database which stores
While implementing XML file reading/writing in my application I saw that when I call
Sometimes while writing Java in Eclipse, I write code that generates warnings. A common
I'm writing an application that uses a SQL Server 2005 database. In the connection
I'm writing an application that uses a SQL Server 2005 database. In the connection
I'm writing an application that reads from a MySQL database and migrates data into
I am writing an ASP.NET class that interfaces with an external application. The flow
I am writing an application that fetches data from MS AX Dynamics once-in-a-very-long-while The
I am writing an sms application that retrieves the messages from a MYSQL database

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.