Latest news:
Sahih al-Bukhari (সহীহ বুখারী) is a free Hadith application for android. This application is advertisement free. Download now https://play.google.com/store/apps/details?id=com.akramhossin.bukharisharif
For connecting to MySQL database using java we need to do following.
Java driver class name for MySQL: com.mysql.jdbc.Driver
Database connection string or connection url: jdbc:mysql://localhost:3306/addressBook
MySQL username: dbUsername
MySQL password: dbPassword
If we need to connect java application to MySQL we need to add one jar file to the application. right click on the libraries under your project propertise , now click on the Add jar/folder and select mysql-connector-java-5.1.23-bin.jar
Below is the example database connection class in java
public class DB {
Connection con = null;
Statement st = null;
ResultSet rs = null;
ResultSetMetaData md = null;
String dburl = "jdbc:mysql://localhost:3306/addressBook";
String dbuser = "root";
String dbpassword = "";
public DB() {
try {
con = DriverManager.getConnection(dburl, dbuser, dbpassword);
st = con.createStatement();
} catch (Exception ex) {
ex.getMessage();
}
}
}
Views : 1076