Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

a question regarding jdbc

  Asked By: Cameron    Date: Dec 19    Category: Java    Views: 771
  

im making this database, and im having a hard time figuring out how i
can connect the program to the database. im using java for the gui
and mysql for the database. i hope someone could help me out! thanks
guys *and gals =)*!

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Maliha Malik     Answered On: Dec 19

openConnection(String username, String password, String database) {
try{
Class.forName("org.gjt.mm.mysql.Driver"); //GNU driver
}
catch (ClassNotFoundException noClass) {
System.out.println(noClass);
}
try {
connection =
DriverManager.getConnection("jdbc:mysql://localhost/databaselocation?user=" +
username + "&password=" + password);
stmt = connection.createStatement();
}

 
Didn't find what you were looking for? Find more on a question regarding jdbc Or get search suggestion and latest updates.




Tagged: