via een omweg dan
De Databases en bindings van macromedia werkt nu!
Een ding dat ik veranderd heb is in mysql een testdatabase (vandaar stomme
namen foo en bar) aanmaken ipv in phpMyAdmin en daarna geopend in phpMyadmin
de rechten toegekend op de juiste inlognaam ed.
Omslachtig, maar er werkt iets , nog wel met veel rommelige code, maar
daarop kan ik verder bouwen hoop ik.
SF
Dit is de werkende code:
<%@ page contentType="text/html; charset=iso-8859-1" language="java"
import="java.sql.*" errorPage="" %>
<%@ include file="WEB-INF/classes/connectie.jsp" %>
<%
Driver Driverconnectie =
(Driver)Class.forName(MM_connectie_DRIVER).newInst ance();
Connection Connconnectie =
DriverManager.getConnection(MM_connectie_STRING,MM _connectie_USERNAME,MM_connectie_PASSWORD);
PreparedStatement Statementconnectie =
Connconnectie.prepareStatement("SELECT foo, bar FROM javastest.testdata");
ResultSet connectie = Statementconnectie.executeQuery();
boolean connectie_isEmpty = !connectie.next();
boolean connectie_hasData = !connectie_isEmpty;
Object connectie_data;
int connectie_numRows = 0;
%>
<%
// *** Recordset Stats, Move To Record, and Go To Record: declare stats
variables
int connectie_first = 1;
int connectie_last = 1;
int connectie_total = -1;
if (connectie_isEmpty) {
connectie_total = connectie_first = connectie_last = 0;
}
//set the number of rows displayed on this page
if (connectie_numRows == 0) {
connectie_numRows = 1;
}
%>
<%
// *** Recordset Stats: if we don't know the record count, manually count
them
if (connectie_total == -1) {
// count the total records by iterating through the recordset
for (connectie_total = 1; connectie.next(); connectie_total++);
// reset the cursor to the beginning
connectie.close();
connectie = Statementconnectie.executeQuery();
connectie_hasData = connectie.next();
// set the number of rows displayed on this page
if (connectie_numRows < 0 || connectie_numRows > connectie_total) {
connectie_numRows = connectie_total;
}
// set the first and last displayed record
connectie_first = Math.min(connectie_first, connectie_total);
connectie_last = Math.min(connectie_first + connectie_numRows - 1,
connectie_total);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="650" border="1">
<tr>
<td width="106"><%=(((connectie_data = connectie.getObject("foo"))==null
|| connectie.wasNull())?"":connectie_data)%></td>
<td width="158">naam</td>
<td width="179">nummer</td>
<td width="179"><%=(((connectie_data = connectie.getObject("bar"))==null
|| connectie.wasNull())?"":connectie_data)%></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><%=(connectie_first)%></td>
<td>eerste connectie </td>
<td>laatste </td>
<td><%=(connectie_last)%></td>
</tr>
<tr>
<td><%=(connectie_total)%></td>
<td>totaal</td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<%
connectie.close();
Statementconnectie.close();
Connconnectie.close();
%>
-----------------------------------------------
dit staat er dan in dat bestand connectie:
<%
String MM_connectie_DRIVER = "org.gjt.mm.mysql.Driver";
String MM_connectie_USERNAME = "<de mijne>";
String MM_connectie_PASSWORD = "<de mijne>";
String MM_connectie_STRING = "jdbc:mysql://localhost:3306/javastest";
%>

Likes:

Quote