Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package tiebreak.DAL;
  6.  
  7. import java.sql.Connection;
  8. import java.sql.DriverManager;
  9. import java.sql.SQLException;
  10.  
  11. /**
  12.  *
  13.  * @author Henrik
  14.  */
  15. public class TBConnection
  16. {
  17.  
  18.     /**
  19.      * Create connection to the database, according to the information listed below.
  20.      * @return
  21.      * @throws SQLServerException
  22.      */
  23.     private static String serverName = "x.x.x.x";
  24.     private static String dbName = "tie-break";
  25.     private static int port = 3306;
  26.     private static String user = "java";
  27.     private static String pass = "java";
  28.  
  29.  
  30.     public static Connection getConnection() throws SQLException
  31.     {
  32.         try
  33.         {
  34.             Class.forName("org.gjt.mm.mysql.Driver");
  35.         }
  36.         catch (Exception E)
  37.         {
  38.             System.err.println("Unable to load driver");
  39.             E.printStackTrace();
  40.         }
  41.         Connection con = DriverManager.getConnection("jdbc:mysql://" + serverName + ":" + port + "/" + dbName, user, pass);
  42.  
  43.         return con;
  44.  
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement