To connect to a database from a JSP page on a premier plan, please paste the following into a jsp page, upload and run using a browser, make sure to relace the values which are surrounded by square brackets in the code below
<%@ page import="java.sql.*" %>
<%
String connectionURL = "jdbc:mysql://localhost:3306/[databasename]";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "[username]", "[password]");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT [field] FROM table");
while (rs.next()) {
out.println(rs.getString("[field]")+"<br>");
}
rs.close();
%>
</body></html>
Back to JSP
Add new attachment
Only authorized users are allowed to upload new attachments.
«
This page (revision-1) was last changed on 14-Nov-2008 14:27 by UnknownAuthor