Hi, To connect to the mysql database u hava to download a driver called "org.gjt.mm.mysql.Driver" . For ur query i am writing a small peice code DriverManager.registerDriver(new Driver()); String s = "jdbc:mysql://126.96.36.199:3306/test"; Class.forName("org.gjt.mm.mysql.Driver"); Connection con = DriverManager.getConnection(s); Rest of the statement are same .
If u dont have the driver and if u dont get the driver on net mail me i will send u the file ------------------ Sandeep Jain
Try and Try Till u succeed<br /> <br />Sandeep Jain
Joined: Oct 25, 2000
I just forgot to mention that the 1)first one is the ip address 2) test -> the database name ------------------ Sandeep Jain
Hi Thomas, I know that your message was posted a long time ago, but could you email me at firstname.lastname@example.org to describe how you put the following into a .properties file. I've been trying this myself and have been experiencing some trouble with it. Thanks for your time.
Joined: Feb 03, 2001
I actually answered my own question with thanks to long sun. I didn;t realize you had to actually set the properties using a properties file. Thanks!!
The JDBC API is designed to run with any complient driver. When you ask JDBC for a connection to a database, the DriverManager needs to know which driver to get it from. It gets this information from the 'jdbc.driver' property stored in the Java System properties. (ie NOT the actual computer properties.) There are (generally) two ways of defining a driver. The easiest is to call Class.forName("fully qualified driver name"). This makes it the driver's responsibility to register itself with JDBC and life goes on. The other way is to define the driver name on the command line when executing the program using the -D<name>=<value> option. (The code above provided by Thomas is equivalent to the first method) A third method that I hadn't thought of is to simply write the driver name directly to the JVM properties, although I don't see any advantage over the Class.forName() method... DOM