Mám takový další dotaz. Jak připojit databázi k jsp?
je to nějak takto
<sql:setDataSource
driver="org.apache.derby.jdbc.EmbeddedDriver"
user=""
password=""
url="jdbc:mysql://D:/NetBeansProjects/DBForum"
dataSource="jdbc:mysql://D:/NetBeansProjects/DBForum"
var="db" scope="application" />
ale nevím jestli je dobře to url a datasource. pro konkrétnost přikládám celý kod i s chybovou hláškou
<sql:setDataSource
driver="org.apache.derby.jdbc.EmbeddedDriver"
user=""
password=""
url="jdbc:mysql://D:/NetBeansProjects/DBForum"
dataSource="jdbc:mysql://D:/NetBeansProjects/DBForum"
var="db" scope="application" />
<form id="registrace" action="registrace.jsp" method="post">
<table class="registrace_tab" width="100%" cellpadding="0" cellspacing="3" border="2">
<tr><td>*Nick:</td><td><input type="text" id="username" name="username" size="25" class="required" /></td></tr>
<tr><td>*Heslo:</td><td><input type="password" id="pass" name="pass" size="25" class="required" /></td></tr>
<tr><td>*Heslo znovu:</td><td><input type="password" id="pass2" name="pass2" size="25" class="required" /></td></tr>
<tr><td>*Přijmení:</td><td><input type="text" id="prijmeni" name="prijmeni" size="25" class="required" /></td></tr>
<tr><td>*Jmeno:</td><td><input type="text" id="jmeno" name="jmeno" size="25" class="required" /></td></tr>
<tr><td>*Email:</td><td><input type="text" id="mail" name="mail" size="25" class="required email" /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="odesli" value="Registrovat" /></td></tr>
</table>
* Takto označené položky jsou povinné
</form>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<sql:update var="add" dataSource="${db}">
insert into Users ("username","pass","mail","jmeno","prijmeni") values (?,?,?,?,?)
<sql:param value="${param.username}"/>
<sql:param value="${param.pass}"/>
<sql:param value="${param.mail}"/>
<sql:param value="${param.jmeno}"/>
<sql:param value="${param.prijmeni}"/>
</sql:update>
</body>
</html>
a chybu to hází takovouto
org.apache.jasper.JasperException: An exception occurred processing JSP page /registrace.jsp at line 20
17: <title>JSP Page</title>
18: </head>
19: <body>
20: <sql:update var="add" dataSource="${db}">
21: insert into Users ("username","pass","mail","jmeno","prijmeni") values (?,?,?,?,?)
22:
23: <sql:param value="${param.username}"/>