Skip to content

Instantly share code, notes, and snippets.

@ayato-p
Last active December 30, 2015 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayato-p/7749088 to your computer and use it in GitHub Desktop.
Save ayato-p/7749088 to your computer and use it in GitHub Desktop.
package database.util;
import com.sun.org.apache.xerces.internal.dom.PSVIAttrNSImpl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
* Created with IntelliJ IDEA.
* User: ayato
* Date: 12/2/13
* Time: 9:07 PM
* To change this template use File | Settings | File Templates.
*/
public final class DatabaseUtil {
public static Connection newConnection() {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/exercise", "root", "pass");
} catch (SQLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (ClassNotFoundException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
return con;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment