JDBC connectorj for MySql Database
Java connects to MySql Database using JDBC driver named Connector/J. I found it a bit interesting in configuring and testing the driver. I previously hadn't connected using Connector/J. In my personal view it's much more easier to connect using php to MySql when you first try your hand. Let me get to the details.
I downloaded Connector/J driver from the ConnectorJ_5.0
You need to download the latest driver. Its around 8 MB which contains both the source and the binary.You are allowed to download either a windows version (Zip) or a Linux version (tar.gz). Anyhow both are compressed form and you need to uncompress for both platform. I used windows hence i will explain the steps involved in windows platform.
First copy the jar file, com and org folders contained in the zip file into one of classpath folders where JVM can find it. I copied mysql-connector-java-5.0.5-bin.jar, com and org folder into a folder named as connectorj in d: drive.
In my case i didn't had the classpath set.
I created a new variable named classpath in the Environmental variable.
Variable name:classpath
Variable value:.;D:\connectorj\mysql-connector-java-5.0.5-bin.jar
For setting classpath and for more information see classpath info in Sun Site or Javapedia
Then i tested the driver using the code,
public class TestCon {
public static void main(String args[]) {
try {
class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("JVM is able to find the driver. Test success");
} catch (Exception e) {
System.out.println("Driver error. Cann't find the driver");
e.printStackTrace();
}
}
}
Compiled using javac TestCon.java and executed by java TestCon for which i got the
JVM is able to find the driver. Test success
This demonstrated that i was able to connect to connectorj driver.
Hope you would also have the same result.
Tuesday, April 10, 2007
Sunday, April 08, 2007
Yeah its been a long time that i have blogged. Seems like ages. To be frank, I had ample time to blog but was somehow not inclined. Probably i needed a break from this. Anyhow now that i am back again, it shouldn't matter.
I remember reading about Rock genre music. It was kinda informative. It was a research done in comparison with other genres like pop etc. It demonstrated that rock genre had positive effect of your mind. It said that the people had a smoothen effect when they listened to rock genre. It also showed that the heat generated by your body would come down in comparison to other genre. It was remarkable, i thought. Since my dad feels that its a sort of scream. I do appreciate his view but tend to disagree. Its his view and we are a democratic country. Now all the music are played with reduced volume and thats democracy in action! I am rebel on the run six gun lover... We all are rebel at teenage. I always wanted more freedom, more liberty to do things. It's my life. I guess we all grow old and history repeats.
Catch you later....
I remember reading about Rock genre music. It was kinda informative. It was a research done in comparison with other genres like pop etc. It demonstrated that rock genre had positive effect of your mind. It said that the people had a smoothen effect when they listened to rock genre. It also showed that the heat generated by your body would come down in comparison to other genre. It was remarkable, i thought. Since my dad feels that its a sort of scream. I do appreciate his view but tend to disagree. Its his view and we are a democratic country. Now all the music are played with reduced volume and thats democracy in action! I am rebel on the run six gun lover... We all are rebel at teenage. I always wanted more freedom, more liberty to do things. It's my life. I guess we all grow old and history repeats.
Catch you later....
Subscribe to:
Posts (Atom)