problem sfs2x and postgresql

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

san-sin
Posts: 3
Joined: 01 Sep 2010, 10:49

problem sfs2x and postgresql

Postby san-sin » 15 Jan 2011, 17:40

Hello.

Sfs2x send me error on starting like

Code: Select all

Exception: org.postgresql.util.PSQLException
Message: Can't use query methods that take a query string on a PreparedStatement.
Description: The DBManager Test SQL failed
Please double check your SQL code and make sure that Database server is running.

But when i run Sms 1.x with the same connection property all is Ok.
I undestend that it is probably my mistake, but have no idea what is it.

Sfs1.x property

Code: Select all

           
<DatabaseManager active="true">
<Driver>org.postgresql.Driver</Driver>
<ConnectionString>jdbc:postgresql://localhost:5432/game_new</ConnectionString>
<UserName>postgres</UserName>
<Password>admin</Password>
<TestSQL><![CDATA[SELECT COUNT(*) FROM users]]></TestSQL>
<MaxActive>10</MaxActive>
<MaxIdle>10</MaxIdle>
<OnExhaustedPool>fail</OnExhaustedPool>
<BlockTime>5000</BlockTime>
</DatabaseManager>


Sfs2x property

Code: Select all

  <databaseManager active="true">
    <driverName>org.postgresql.Driver</driverName>
    <connectionString>jdbc:postgresql://127.0.0.1:5432/game</connectionString>
    <userName>postgres</userName>
    <password>admin</password>
    <testSql>SELECT COUNT(*) FROM users</testSql>
    <maxActiveConnections>10</maxActiveConnections>
    <maxIdleConnections>10</maxIdleConnections>
    <exhaustedPoolAction>FAIL</exhaustedPoolAction>
    <blockTime>5000</blockTime>
  </databaseManager>
[/code]

I use prostgre 8.4(windows) or 8.3(ubuntu)
san-sin
Posts: 3
Joined: 01 Sep 2010, 10:49

Postby san-sin » 15 Jan 2011, 20:21

As i understend it's not criminal, becouse this error is only on startup.
I can use SFSDBManager in server extensions.
laskovdm
Posts: 4
Joined: 18 Jan 2011, 08:16

Postby laskovdm » 18 Jan 2011, 08:22

Dear gotoandplay(), please answer on that. :)
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 19 Jan 2011, 07:34

Have you tried with another test query? Does it always report the same error?
Lapo
--
gotoAndPlay()
...addicted to flash games
laskovdm
Posts: 4
Joined: 18 Jan 2011, 08:16

Postby laskovdm » 19 Jan 2011, 07:46

Lapo wrote:Have you tried with another test query? Does it always report the same error?


Yep, i tried more simple requests. And some syntax experiments. And also - different postgre connectors.

SFS2 gives such error (with no useful comments in logs, that is the problem too), but properly working after that.

___
Ubuntu 9.04 (server, x64) + Postgre 8.3 + latest Sun JDK + SFS2
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Jan 2011, 09:44

The problem doesn't pose any issue to your database connection, don't worry. It's just a check. We'll see if we can replicate it and will let you know.
Lapo

--

gotoAndPlay()

...addicted to flash games
san-sin
Posts: 3
Joined: 01 Sep 2010, 10:49

Postby san-sin » 20 Jan 2011, 21:32

The same problem if I try

Code: Select all

String sql = "UPDATE stats SET money=" + money + " WHERE id=" + statsId;
dbManager.executeUpdate(sql);


but if

Code: Select all

String sql = "UPDATE stats SET money=" + money + " WHERE id=?";
psmt = connection.prepareStatement(sql);
psmt.setInt(1, statsId);
psmt.executeUpdate();

all is ok.

In first case I've java exception

Code: Select all

UserUtil.loginorg.postgresql.util.PSQLException: Can't use query methods that take a query string on a PreparedStatement.at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:292)
       
at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
at com.smartfoxserver.v2.db.SFSDBManager.executeUpdate(SFSDBManager.java:201)
at com.smartfoxserver.v2.db.SFSDBManager.executeUpdate(SFSDBManager.java:174)
at com.test.myprg.UserUtil.login(UserUtil.java:46)
at com.test.myprg.UserInfoExtension.handleClientRequest(UserInfoExtension.java:83)
at com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:137)
at com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


may be it could help))
User avatar
Stigma
Posts: 15
Joined: 22 Feb 2010, 13:30
Location: Switzerland

Postby Stigma » 03 Feb 2011, 17:40

same problem
dingo
Posts: 98
Joined: 27 Jan 2009, 21:34

Postby dingo » 03 Feb 2011, 21:28

to save you some headaches, here's are some current inconveniences in the dbmanager:

1. executeQuery won't work if any of your field values are null
viewtopic.php?t=9436

2. ISFSArray result = db.executeQuery(sql, new Object[]{name}); won't work: viewtopic.php?t=9705

3. aliasing is not yet supported viewtopic.php?p=40670
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 04 Feb 2011, 12:59

We plan to release a "nightly build" next week with a series of hotfixes including those related to the DBManager.
I will keep you updated.

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 04 Feb 2011, 14:24

Hi Lapo, have you already solved the problem when using executeQuery and executeUpdate with H2Database?
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
dingo
Posts: 98
Joined: 27 Jan 2009, 21:34

Postby dingo » 07 Feb 2011, 16:20

Lapo wrote:We plan to release a "nightly build" next week with a series of hotfixes including those related to the DBManager.
I will keep you updated.

hope it helps


great news Lapo, looking forward to it.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 83 guests