We would like to know how to connect to local host using JDBC.
import java.sql.Connection; import java.sql.DriverManager; /* w ww. ja v a 2s . co m*/ public class Main { public static void main(String[] argv) throws Exception { String driverName = "org.gjt.mm.mysql.Driver"; Class.forName(driverName); String serverName = "localhost"; String mydatabase = "mydatabase"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "username"; String password = "password"; Connection connection = DriverManager.getConnection(url, username, password); } }