can we use anything else instead of Class.forName() for loading a driver for jdbc connectivity
i.e is first step of jdbc connection?
Asked
Active
Viewed 1,905 times
1
SpringLearner
- 13,738
- 20
- 78
- 116
user2884161
- 11
- 2
-
Why would you do that? – Harald K Oct 15 '13 at 21:13
-
Does this answer your question? [JDBC Class.forName vs DriverManager.registerDriver](https://stackoverflow.com/questions/5484227/jdbc-class-forname-vs-drivermanager-registerdriver) – Stephen C Aug 05 '21 at 01:35
2 Answers
2
can we use anything else instead of "Class.forname" for loading a driver for jdbc connectivity i.e is first step of jdbc connection?
You haven't even needed that since JDBC 4.1. Just call DriverManager.getConnection() with an appropriate URL.
Mark Rotteveel
- 100,966
- 191
- 140
- 197
user207421
- 305,947
- 44
- 307
- 483
0
Just import java.sql.Driver and invoke DriverManager.getConnecion() to establish a database connection. You don't really need to call Call.forName() these days (java7).