4May/115
Connect Java to MYSQL using JDBC
Most of the System requires a back end in order to save the transactions. Here is the sample how to connect your java apps into mysql database.
import java.sql.*
public class MysqlConnect{
Connection con = null; String dbUser = "root"; String dbPwd = "password"; String selectedDb = "test"; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost/selectedDb", dbUSer, dbPwd); if(!con.isClosed()) System.out.println("Successfully connected to " + "MySQL server using TCP/IP..."); } catch(Exception e) { System.err.println("Exception: " + e.getMessage()); } }