Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static HttpServletResponse getData(HttpServletResponse response)
- throws SQLException, InstantiationException,
- IllegalAccessException, ClassNotFoundException, IOException {
- System.out
- .println("-------- MySQL JDBC Connection Testing ------------");//debug stmt
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- System.out.println("Where is your MySQL JDBC Driver?");//debug stmt
- e.printStackTrace();
- return null;
- }
- System.out.println("MySQL JDBC Driver Registered!");//debug stmt
- Connection connection = null;
- try {
- connection = DriverManager
- .getConnection("jdbc:mysql://localhost:3306/DBNAME",
- "USERNAME", "PASSWORD");
- } catch (SQLException e) {
- System.out.println("Connection Failed! Check output console");//debug stmt
- e.printStackTrace();
- return null;
- }
- if (connection != null) {
- System.out.println("You made it, take control your database now!");//debug stmt
- // DB Verbindung steht: ab hier kann Programmiert werden
- }
- } else {// Falls die Verbindung nicht funktioniert hat
- System.out.println("Failed to make connection!");//debug stmt
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement