Is there any other way to load DB driver than class.forName?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Modern JDBC drivers are supposed to provide enough metadata in their jar file manifest, so you may not need to do anything.
The main point of
Class#forNameis to remove the compile-time dependency on the particular JDBC driver (and make it configurable at run-time). If you are using Oracle driver code in your program anyway (to use their non-standard JDBC extensions) and have no compulsions to hardcode the driver class name, you can also just create a regular instance of the driver class.