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 24-May-2017 15:30 by UnknownAuthor
G’day (anonymous guest) My Prefs
  • View Page Source
  • This clear IPSec security association,
    clear ipsec sa peer X.X.X.X
    

All Pages

Page views: 1851

Private Tomcat

Linux

MySQL

Email

SQL Server

ASP

JSP

C#

Web Mail

Windows Plesk

Linux Plesk

PHP

Gaming

ASP.NET

Persits ASPUpload

Wiki Help

Referring Pages:
...nobody

JSPWiki v2.8.1