You are on page 1of 1

import java.sql.

Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionManager {

public static final String HOSTNAME = "jdbc:mysql://localhost:3306/";


public static final String USERNAME = "root";
public static final String PASSWORD = "root";
public static final String DB = "searchbook";
public static Connection con;
private ConnectionManager(){
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}

public static Connection getInstance() {


if(con == null) {
con = new Connection();
}
return instance;
}
}
public static Connection getConnection(boolean autoCommit) {
try {
DriverManager.getConnection(HOSTNAME, USERNAME,PASSWORD);
} catch (SQLException e) {
e.printStackTrace();
}
return con;
}