Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page import = "java.sql.Connection" %>
- <%@ page import = "java.sql.DriverManager" %>
- <%@ page import = "java.sql.SQLException" %>
- <%@ page import = "java.util.Properties" %>
- <html>
- <!--- test koneksi ke server MySQL menggunakan bahasa pemrograman JSP.
- Sebelumnya copy paste terlebih dahulu driver MYSQL J Connector
- ke path C:\apache-tomcat-8.0.23\lib (Windows).
- Referensi: http://stackoverflow.com/questions/5556664/how-to-fix-no-suitable-driver-found-for-jdbcmysql-localhost-dbname-error-w
- -->
- <head>
- <title>Koneksi Database</title>
- </head>
- <body>
- <%
- try{
- DriverManager.registerDriver(new com.mysql.jdbc.Driver());
- Connection koneksi = null;
- String url = "jdbc:mysql://localhost:3306/pdam";
- String user = "root";
- String password = "kucing";
- koneksi = DriverManager.getConnection(url,user,password);
- if(koneksi != null);
- out.println("Berhasil Terkoneksi ke Database");
- koneksi.close();
- }catch(Exception ex){
- out.println("Gagal Terkoneksi " + ex);
- }
- %>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement