Jump to content
  • 0

[HELP] Code in Eclipse - Execute SQL Problem!


[DEV]DjSt3rios

Question

Hi guys. I need some help. I am trying to make a command //addhero, and i want this command to add the target automatically in target "heroes", but it does not execute! take a look:

 

else if (command.startsWith("admin_addhero"))
	{
            int targetid = target.getObjectId();
            String targetname = target.getName();
            int targetclassid = ((L2PcInstance) target).getClassId().getId();
            _log.warn("Setting Values..");
            
            con = L2DatabaseFactory.getInstance().getConnection();
            
            _log.warn("Connected!");
            /*statement = con.prepareStatement(RE_ADD_HERO);
            statement.setInt(1, targetid);
            statement.execute();
            statement.close();
            _log.warn("Removed Played from hero");*/
            
            PreparedStatement statement;
            statement = con.prepareStatement("INSERT INTO heroes (char_id,char_name,classid,count,played) VALUES (?,?,?,?,?)");
            _log.warn("started...");
            statement.setInt(1, targetid);
            _log.warn("Char OBJ ID: " + targetid);
            statement.setString(2, targetname);
            _log.warn("Name: " + targetname);
            statement.setInt(3, 114);
            _log.warn("Class ID: " + targetclassid);
            statement.setInt(4, 1);
            statement.setInt(5, 1);
                    _log.warn("Trying to Execute...");
            statement.execute();
            _log.warn("Executed");
            statement.close();
            con.close();
            _log.warn("Added Player as Hero");
            _log.warn("Success!");
        }
        catch (Exception e)
        {
        	_log.debug("Hero Add Error");
        }
        finally
		{
			try
			{
				con.close();
			}
			catch (Exception e)
			{
			}
		}
	}

 

Its not finished yet, But still look at this. When i do the command in console it appears this: "Trying to Execute..." but it does not appear this: "Executed" Which means everything after statement.execute() it doesnt work. So this code has problem, but i cant understand what's wrong. Please help me. Thanks

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...