-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Wileynet wrote:
Here is another beginner question of sorts I imagine. I receive this error. java.sql.SQLException: Update failed, possible duplicate entry
I've got this code in a .jsp page.
<% String ref=request.getHeader("Referer");%>
<BR>
<% count.addInfo( ref );
%>
count is calling the method addInfo in a java bean...
public void addInfo( String Referer )
throws SQLException, Exception {
if (con != null) {
try{
PreparedStatement updateInfo;
updateInfo = con.prepareStatement(
"insert into info(?);");
updateInfo.setString(1,Referer);
updateInfo.execute();
}
catch (SQLException sqle) {
error = "Update failed, possible duplicate entry";
throw new SQLException( error );
}
} else {
error = "Connection with database was lost.";
throw new Exception( error );
}
}
Can anyone see the mistake I am making here. My database has one table now called info with one String field which is the primary key also.
Thanks if anyone can help or point me to a webpage or something.
-wiley
Also, looking at your code, you have a SQL syntax error. Only the mysql command-line client requires statements terminated with a ";", so you should write:
updateInfo = con.prepareStatement("insert into info(?)");
not:
updateInfo = con.prepareStatement("insert into info(?);");
-Mark
- -- MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/
For technical support contracts, visit https://order.mysql.com/?ref=mmma
__ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mark Matthews <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java /_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA <___/ www.mysql.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.1.90 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+f8xFtvXNTca6JD8RAhArAJ98UE5FFTYc4iok9r62OgjJiIFm+QCgnnhk oxDuUCf1Qz/tOIzNCkEQcV4= =VwpN -----END PGP SIGNATURE-----
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]