0

I’m brand new do Java’s JDBC. I’ve designed a database for a Java application that I’m building, and have read some about the Class.forName() method, but I’m not sure what driver to set it to.

I’ve tried searching the SQL Server files to find the “Driver”, and have searched online for information with nothing helpful as of yet.

I found a SQL Server driver outside on the web, but wasn’t sure if, since it’s not coupled with the files of the actual program, that I’d be able to use it or not.

  • 2
    Try writing your program without this line of code. You should not need it (in most typical circumstances). This line appears in many older (out-of-date) tutorials and examples. Otherwise, if you still have issues, show us your code and the specific error you get. But please research first - your question has probably already been asked and answered. – andrewJames Jan 18 '23 at 00:19
  • Related: [What is the actual use of Class.forName("oracle.jdbc.driver.OracleDriver") while connecting to a database?](https://stackoverflow.com/q/8053095/12567365) Modern JDBC drivers, used with modern versions of Java do not require the use of `Class.forName()` (mostly). – andrewJames Jan 18 '23 at 00:19
  • If you're using a modern(ish) sql server jdbc driver, it should be enough to put it on your classpath and then just create connection from DriverManager. New drivers do this Class.forName thing automatically / register them as service providers so you don't have to. – siggemannen Jan 18 '23 at 14:00

0 Answers0