How to connect a database to a java program?
Hello techyv,
How can I connect a database to a java program, just like what visual basic do? Waiting for your answer.
Thanks experts.
Hello techyv,
How can I connect a database to a java program, just like what visual basic do? Waiting for your answer.
Thanks experts.
Type this on the top of your code:
Import java.sql.Connection;
Import java.sql.DriveManager;
Import java.sql.SQLException;
Try to add these codes:
Connection con=DriveManager.getConnection (detail,detail,detail); Â >> (This will serve as your connection from database to java)
Example:
Import java.sql.Connection;
Import java.sql.DriveManager;
Import java.sql.SQLException;
Â
public class DBConnectÂ
{
public static void main (String[] args)
{
String Uname= "details";
String Upword="details";
Connection con=DriveManager.getConnection (Uname,Upword);
}
}
Hi Lee,
Mr. Jeany math here has given a process to connect a database to a java program. it is really an efficient way. If you are looking something more than it, you can visit this link:
http://www.homeandlearn.co.uk/java/connect_to_a_database_using_java_code.html
You will get all your answers from here. Thanks.