Jump to content
  • 0

Get Info From Database to Community


Question

Posted

Hello! i'm trying to show info from database into CommunityBoard. I would like to show, if the clan has ClanHall or Fortress, etc. I write this but its getting an error and i dont know why.

 

java.sql.SQLException: Before start of result set
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
        at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:781)
        at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5239)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5162)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5201)
        at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:263)
        at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:263)
        at l2r.gameserver.model.L2Clan.getHideOutName(L2Clan.java:3014)
        at l2r.gameserver.communitybbs.Managers.ClanBBSManager.clanhome(ClanBBSManager.java:253)
        at l2r.gameserver.communitybbs.Managers.ClanBBSManager.clanhome(ClanBBSManager.java:234)
        at l2r.gameserver.communitybbs.Managers.ClanBBSManager.cbByPass(ClanBBSManager.java:50)
        at l2r.gameserver.communitybbs.BoardsManager.handleCommands(BoardsManager.java:80)
        at l2r.gameserver.network.clientpackets.RequestBypassToServer.runImpl(RequestBypassToServer.java:251)
        at l2r.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:71)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

 

 

This is the backEnd.

 

public String getHideOutName(int ownerId)
	{
		String x = null;
		
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement ps = con.prepareStatement("SELECT DISTINCT name FROM `clanhall` cl INNER JOIN `clan_data` c ON cl.ownerId = ?");)
		{
			ps.setInt(1, ownerId);
			ResultSet rs = ps.executeQuery();
			
			x = rs.getString("name");
			
		}
		catch (SQLException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (x == null)
		{
			return "None";
		}
		return x;
	}

 

Please, someone can give me a hand with this?.
Thanks!!

3 answers to this question

Recommended Posts

  • 1
Posted (edited)
1 hour ago, barao45 said:

Hello! i'm trying to show info from database into CommunityBoard. I would like to show, if the clan has ClanHall or Fortress, etc. I write this but its getting an error and i dont know why.

 

java.sql.SQLException: Before start of result set
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
        at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:781)
        at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5239)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5162)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5201)
        at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:263)
        at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:263)
        at l2r.gameserver.model.L2Clan.getHideOutName(L2Clan.java:3014)
        at l2r.gameserver.communitybbs.Managers.ClanBBSManager.clanhome(ClanBBSManager.java:253)
        at l2r.gameserver.communitybbs.Managers.ClanBBSManager.clanhome(ClanBBSManager.java:234)
        at l2r.gameserver.communitybbs.Managers.ClanBBSManager.cbByPass(ClanBBSManager.java:50)
        at l2r.gameserver.communitybbs.BoardsManager.handleCommands(BoardsManager.java:80)
        at l2r.gameserver.network.clientpackets.RequestBypassToServer.runImpl(RequestBypassToServer.java:251)
        at l2r.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:71)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

 

 

This is the backEnd.

 

public String getHideOutName(int ownerId)
	{
		String x = null;
		
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement ps = con.prepareStatement("SELECT DISTINCT name FROM `clanhall` cl INNER JOIN `clan_data` c ON cl.ownerId = ?");)
		{
			ps.setInt(1, ownerId);
			ResultSet rs = ps.executeQuery();
			
			x = rs.getString("name");
			
		}
		catch (SQLException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (x == null)
		{
			return "None";
		}
		return x;
	}

 

Please, someone can give me a hand with this?.
Thanks!!

First it is necessary to know if what you need is to recover one or several values, if you need several then you must add the values of the result in a list but the following form:
while(rs.next()){ list.add(rs.getString("name")); }
And if you only need to retrieve a single value which is what I assume you want to do, you should limit your result to a by placing at the end of your query Limit 1
And you could put your assignment like this:
x = (rs.getString("name") != null) ? rs.getString("name") : "None";

Edited by TGSLineage2
Guest
This topic is now closed to further replies.


  • Posts

    • Lol good joke.   If I'd be the one contacting yo then I'd say at least 50% in advance because you can basically just fuck off when things doesn't go your way, and then you as a developer just wasted days or even weeks of time with development.
    • "Just make your own game!" sounds simple until you’ve tried it. I did, with Epic Dragon World and learned the hard way that "open source" often means "free labor for resellers." The MIT license became a buffet for people to grab code, rebrand it and ghost the project. Even basic collaboration collapsed because everyone wanted their vision, not *a* vision. NCSoft’s lawyers aren’t theoretical. They’re a sword of Damocles. Even if you rebuild a client from scratch, if it feels like Lineage 2, they’ll come knocking. Ask the Chrono Trigger fangame corpses how that goes. MMOs are hospice care. The genre’s on life support, kept alive by whales and nostalgia. Look at Throne and Liberty, NCSoft’s own "successor" to L2, flopping harder than a 2004 PKer in ToI. Classic reboots (WoW, L2) are bandaids, not resurrections. This is the hobby. Optimizing old systems, reverse-engineering spaghetti code and preserving janky mechanics is the fun part. Monetizing it turns it into customer service hell. No thanks. Community? What community? The L2 scene is 90% resellers, 10% players who’ll quit the second they don’t get +16 on day one. Both asking how to install Java and why running the uncompiled server does not work.
    • Dear players, Open beta test for C3 begins today at 19:00 server time (GMT +2). 💰 All participants who find bugs during OBT will be rewarded with Coin of Luck (CoL): - 1 CoL for each staticmesh issue found — e.g., walking through textures, etc., - 2 CoL or more for server-side issues, depending on their severity., We strongly recommend reviewing the quest list - when switching to Chronicle 3, the total number of quests should match the number shown in the upper right corner of the window and correspond to the quest count from Chronicle 2. To log into the game, use the same data you use to access the Airin server. 📌 Download client: Google Drive
    • 🔥 Sale Alert! 🔥 Twitter Accounts with 50 Followers — now on SALE! Looking to launch a project or warm up your account base fast? We’ve got starter Twitter accounts with ~50 followers at a sweet price. 💰 Limited-time offer – while stock lasts! ✅ Organic-Looking ✅ Clean & Safe ✅ Perfect for boosting credibility 📦 Instant delivery
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock