Commit | Line | Data |
---|---|---|
86398330 JB |
1 | <%@ page import="java.io.*, java.util.*, javax.servlet.*, java.sql.*" %> |
2 | <% | |
3 | ||
d2793705 | 4 | Connection connection = null; |
86398330 | 5 | try { |
d2793705 | 6 | String connectionURL = "jdbc:mysql://localhost/MyBd?useUnicode=yes&characterEncoding=UTF-8"; |
86398330 | 7 | Class.forName("com.mysql.jdbc.Driver").newInstance(); |
714e1b91 | 8 | connection = DriverManager.getConnection(connectionURL, "MyBd", "MyBd"); |
86398330 JB |
9 | if(!connection.isClosed()) |
10 | out.println("Successfully connected to " + connectionURL + " MySQL server using TCP/IP"); | |
86398330 | 11 | } catch (Exception e){ |
d2793705 JB |
12 | out.println("Unable to connect to database: " + e); |
13 | } | |
14 | finally { | |
15 | if (connection != null) | |
16 | connection.close(); | |
86398330 JB |
17 | } |
18 | ||
19 | %> |