|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Code:
<%@ page language="java" import="java.sql.*" %>
<%!
// define variables
String site_links;
String tutorials;
// define database parameters
String host="localhost";
String user="****";
String pass="****";
String db="articles;
String conn;
%>
<%
Class.forName("org.gjt.mm.mysql.Driver");
// create connection string
conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user
+ "&password=" + pass;
// pass database parameters to JDBC driver
Connection Conn = DriverManager.getConnection(conn);
// query statement
Statement SQLStatement = Conn.createStatement();
// generate query
String Query = "SELECT * FROM site_links tutorials";
// get result
ResultSet SQLResult = SQLStatement.executeQuery(Query);
while(SQLResult.next())
{
site_links = SQLResult.getString("site_links");
tutorials = SQLResult.getString("tutorials");
}
// close connection
SQLResult.close();
SQLStatement.close();
Conn.close();
%>
ok i am trying to get the results from the database. what i am trying to get is a particular category within the mysql database. allow me to explain, ok the database name is named articles ok, the table is called site_links and i am trying to get the category of tutorials to be called and displayed with this script. so far no luck how can i get this to work. ![]()
__________________
Apache Expert |
|
#2
|
||||
|
||||
|
What is your problem ? No connection ? Wrong driver ? Null values ?
|
|
#3
|
|||
|
|||
|
Connecting to MySQL using JSP is not difficult. You just need to follow the steps at http://jakarta.apache.org/tomcat/to...ples-howto.html or http://jakarta.apache.org/tomcat/to...ples-howto.html.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > HELP!!! getting results using mysql & jsp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|