Could not locate DB Driver
ok... hvor er fejlen henne?? Den kan ikke finde mine db drivers til mysql...KODE:
------------------------------------------------------
Bønnen:
package flash;
import java.sql.*;
import java.util.*;
public class newz {
String error;
Connection con;
public newz() { }
public void connect() throws ClassNotFoundException,SQLException,Exception
{
try {
Class.forName(\"org.gjt.mm.mysql.Driver\").newInstance();
con = DriverManager.getConnection(
\"jdbc:mysql://localhost:3306/flash?user=wasabi&password=memborg\");
} catch (ClassNotFoundException cnfe) {
error = \"ClassNotFoundException: Could not locate DB driver.\";
throw new ClassNotFoundException(error);
} catch (SQLException cnfe) {
error = \"SQLException: Could not connect to database.\";
throw new SQLException(error);
} catch (Exception e) {
error = \"Exception: An unknown error occurred while connecting \" +
\"to database.\";
throw new Exception(error);
}
}
public void disconnect() throws SQLException {
try {
if ( con != null ) {
con.close();
}
} catch (SQLException sqle) {
error = (\"SQLException: Unable to close the database connection.\");
throw new SQLException(error);
}
}
public ResultSet viewNewz() throws SQLException, Exception {
ResultSet rs = null;
try {
String queryString = (\"SELECT * FROM newz;\");
Statement stmt = con.createStatement();
rs = stmt.executeQuery(queryString);
} catch (SQLException sqle) {
error = \"SQLException: Could not execute the query.\";
throw new SQLException(error);
} catch (Exception e) {
error = \"An exception occured while retrieving newz.\";
throw new Exception(error);
}
return rs;
}
public void addNewz(int id, String newz)
throws SQLException, Exception {
if (con != null) {
try {
PreparedStatement updatebooks;
updatebooks = con.prepareStatement(
\"insert into newz values(?, ?);\");
updatebooks.setInt(1, id);
updatebooks.setString(2, newz);
updatebooks.execute();
} catch (SQLException sqle) {
error = \"SQLException: update failed, possible duplicate entry\";
throw new SQLException(error);
}
} else {
error = \"Exception: Connection to database was lost.\";
throw new Exception(error);
}
}
}
JSP\'en:
<%@ page language=\"java\"
import=\"java.sql.*, java.io.*, java.util.*, flash.*\"
%>
<jsp:useBean id=\"newz\" class=\"flash.newz\" />
<html>
<head>
<title> Newz List </title>
</head>
<body>
<a href=\"newbook.jsp\"><b>Add More Newz</b></a>
<form action=\"delete.jsp\" method=\"post\">
<table border=\"1\">
<tr>
<td><b>ID:</b></td>
<td><B>Title:</b></td>
</tr>
<%
newz.connect();
ResultSet rs = newz.viewNewz();
while (rs.next()) {
%>
<tr>
<td>
<input type=\"checkbox\" name=\"pkey\"
value=\"<%= rs.getString(\"newz_ID\") %>\" />
</td>
<td><%= rs.getString(\"newz\") %></td>
</tr>
<%
}
%>
</table><br />
Check newz for deletion.<BR>
<input type=\"submit\" value=\"Delete All Checked Newz\">
</form>
<% newz.disconnect(); %>
</body>
</html>
Jeg bruger Resin som serer udvidelse til IIS...
Sig lige til hvis man mangler resin.conf
