How to connect a database to a java program?

Asked By 0 points N/A Posted on -
qa-featured

Hello techyv,

How can I connect a database to a java program, just like what visual basic do? Waiting for your answer.

Thanks experts.

SHARE
Best Answer by Jeany Math
Best Answer
Best Answer
Answered By 0 points N/A #102327

How to connect a database to a java program?

qa-featured

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);

}

}

Answered By 0 points N/A #102328

How to connect a database to a java program?

qa-featured

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.

Related Questions