Jump to content
  • 0

[HELP] Java Script/SQLException error


Question

Posted

when i call this function gives me error like this.

 

i tried both functions

ResultSet result = statement.executeUpdate();

and

ResultSet result = statement.executeQuery();

and same reaction on both scropts

 

Oct 13, 2012 9:45:18 PM com.l2jserver.gameserver.communitybbs.Manager.BuffBBSManager showBuffMainPage
WARNING: Could get data from character: 
java.sql.SQLException: Can not issue executeUpdate() for SELECTs
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2412)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2371)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2355)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:477)
at com.l2jserver.gameserver.communitybbs.Manager.BuffBBSManager.showBuffMainPage(BuffBBSManager.java:129)
at com.l2jserver.gameserver.communitybbs.Manager.BuffBBSManager.parsecmd(BuffBBSManager.java:38)
at com.l2jserver.gameserver.communitybbs.CommunityBoard.handleCommands(CommunityBoard.java:59)
at com.l2jserver.gameserver.network.clientpackets.RequestBypassToServer.runImpl(RequestBypassToServer.java:234)
at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:60)
at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1073)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

 

private void showBuffMainPage(L2PcInstance activeChar)
{
	try(Connection con = L2DatabaseFactory.getInstance().getConnection())
	{
		PreparedStatement statement = con.prepareStatement("SELECT * FROM character_bbs_buff_save WHERE charId=?");
		statement.setInt(1, activeChar.getObjectId());
		ResultSet result = statement.executeUpdate();
		TextBuilder html = new TextBuilder();
		html.append("<table width=220>");
		while (result.next())
		{
			String name = result.getString("scheme_name");
			html.append("<tr>");
			html.append("<td>");
			if (name.equals(null))
			{
				html.append("No Scheme");
			}
			else
			{
				html.append("<button value=\"" + name + "\" action=\"bypass _bbsbuff;use;" + name + "\" width=190 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
			}
			html.append("</td>");
			html.append("</tr>");
		}
		html.append("</table>");

		result.close();
		statement.close();

		String content = HtmCache.getInstance().getHtmForce(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/buffer.htm");
		content = content.replace("%scheme_list%", html.toString());
		separateAndSend(content, activeChar);
	}
	catch (Exception e)
	{
		_log.log(Level.WARNING, "Could get data from character: ", e);
	}
}

2 answers to this question

Recommended Posts

  • 0
Posted

executeQuery() method is used mostly for SELECT statement. executeUpdate() method is generally used by INSERT, UPDATE,  And DELETE statements.

You can also try the execute() method see if that works

Guest
This topic is now closed to further replies.


×
×
  • Create New...