L2JDP Revision n/a:
Hi again,
Let's say I have such part of code, where I'm checking for an item DEFINED in config file:
Code: Select all
if(player.getInventory().getItemByItemId(Config.NEEDED_ITEM) == null) {player.sendMessage("You run out of " + //and bump... ); return;}
I can get that item name from DB, but the questions are:
1. Is it effective?
2. How to pull out a single string from DB, let's say I have a custom method like this:
Code: Select all
public final String GetItemNameFromDB(){ String itemName = new String(); try { Connection conn = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = conn.prepareStatement("SELECT name FROM etcitem WHERE item_id = " + Config.NEEDED_ITEM); ResultSet rset = statement.executeQuery(); itemName = //... now, how to get that string? conn.close(); statement.close(); } catch(SQLException e) { e.printStackTrace(); } return itemName;}
Thx in advance
Tom
P.S. If my topic doesn't fit into this venue, pls move it (I need to earn the rights to post in Custom Section) Sorry and Thank You!