I have recently started jdbc nd now i am confused that what is the real purpose of Class.forname() method??
Also what is the diff. between Class.forname() and DriverManager.registerDriver()??
plz reply soon
registerDriver is the "old" form. The driver classes are to do that themselves when loaded (the reason for the Class.forName() call). In fact, in Java 6 and later, if the driver implements the Services interface (which it must do to qualify as a valid Java 6 JDBC driver (JDBC version 4.0, I believe) not Type 4, there is a difference between the JDBC version and the Type), you don't have to do either of those.
It's not really an interface. See this, section 9.2.1. It is actually the jdbc.services system property (which is can, of course, also be set in the control panel, and in JNLP and jws configurations). I swear I have read somewhere that when the manifest is set up properly that you don't even need to set that property (which is what I meant by the Services interface), but I can't, for the life of me, find it now. Maybe it was only in relationtion to JEE 6 capable containers.
I swear I have read somewhere that when the manifest is set up properly that you don't even need to set that property (which is what I meant by the Services interface), but I can't, for the life of me, find it now. Maybe it was only in relationtion to JEE 6 capable containers.
You are probably talking about the ServiceLoader class which was introduced in Mustang. Derby uses this for loading and registering its client drivers whenever you have the derby-client.jar in your classpath.
Back to the OPs question.
The Class.forName("driver class name") causes the class to be read and the static block in it to execute.
The static block creates an instance of the Driver class and calls:
to register it
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.