Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static private String database = "fuhrpark";
- static private String conn = "jdbc:mysql://localhost/";
- static private String user = "root";
- static private String password = "";
- static private Connection connection;
- static Connection getConnection()
- {
- if (connection==null)
- {
- try
- {
- // lade Treiberklasse
- Class.forName("com.mysql.jdbc.Driver");
- // erzeuge Verbindung zur DB mit den angegebenen Daten
- connection = DriverManager.getConnection(conn+database+user+password);
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- return connection;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement