-
Notifications
You must be signed in to change notification settings - Fork 0
/
select_example.jsp
43 lines (30 loc) · 993 Bytes
/
select_example.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<%@page language="java" %>
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%@page import="com.mysql.jdbc.*" %>
<%
try {
java.sql.Connection con = null;
String url = "";
String p1 = request.getParameter("parameter_1");
String p2 = request.getParameter("parameter_2");
out.println("debug: " + p1);
//query
String query = "select * from users";
//open sql:
Class.forName("com.mysql.jdbc.Driver").newInstance();
url = "jdbc:mysql://localhost:3306/gordie";
con = DriverManager.getConnection(url, "gordie", "happy95");
java.sql.Statement stmt = con.createStatement();
//executes the query:
java.sql.ResultSet rs = stmt.executeQuery(query);
String p_key = "";
//loop through result set until there is no more data
while(rs.next())
{
p_key = rs.getString("p_key_from_table");
} //end while
} catch (Exception e) {
out.println(e);
}
%>