user2884161
user2884161

Reputation: 11

jdbc connection "alternative to Class.forname for driver loading"

can we use anything else instead of Class.forName() for loading a driver for jdbc connectivity i.e is first step of jdbc connection?

Upvotes: 1

Views: 2064

Answers (2)

user2886301
user2886301

Reputation: 1

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).

Upvotes: 0

user207421
user207421

Reputation: 310874

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.

Upvotes: 2

Related Questions