Sunday, June 15, 2014

How to Run JDBC program through cmd

Okay fine welcome back upto now we have seen how to write a JDBC program. Do you remember the diagram of JDBC API there is a driver in between JDBC API and Database. That driver comes into picture while getting our program executed.Okay lets see how to do
>>Find the driver i.e ojdbc14.jar file in the path  C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib
copy the jar file and paste it in your current directory where your source files(.java) are present.

>>To compile : Open cmd and type javac -cp ojdbc14.jar Insert.java






















>>To run  : java -cp ojdbc14.jar; Insert





















Note: If we donot copy jar file ojdbc14 to the current directory we have to say the path of jar file while compiling and running to JVM so that all the classes present int the jar file are loaded and get executed. If we donot mention the classpath correctly famous classNotFoundException may arise.


No comments :

Post a Comment

Designed By Seo Blogger Templates