TypeError: sql.query is not a function

170 views
Skip to first unread message

JJuN

unread,
Jul 23, 2011, 9:16:02 PM7/23/11
to APE Project


Hello

I've got another problem in mysql

in serverside script i'm trying to use mysql demo (http://www.ape-
project.org/wiki/index.php/Serverside_js_module_using_MySQL)

in this demo i've got a problem with function query

myserver show a error message /var/ape/db/db_test.js 26:TypeError:
sql.query is not a function

how can i solve this problem;;

i use version 1.1.1

thanks for reading :)

Pierre-Olivier

unread,
Jul 24, 2011, 6:45:01 AM7/24/11
to ape-p...@googlegroups.com
Hello

Same error.
I use compiled source from git (1.1.2-dev).
I noticed that event "onConnect" isn't called.

My code for the connection:

var sql = null;

Ape.log("Mysql...");
sql = new Ape.MySQL("192.168.1.100:3306", "xx", "xx", "xx");
sql.onConnect = function() {
Ape.log("Connected !\n");
}


And where i have error:

Ape.registerHookCmd("connect", function(params, info) {
/*
...
...
*/
sql.query("INSERT INTO usersVALUES ('xx','xx')", function(res, errorNo) { 
 if (errorNo) Ape.log('Request error : ' + errorNo + ' : '+ this.errorString()); 
});

/*
...
...
*/
}

Nicolas Guibert

unread,
Jul 27, 2011, 10:43:15 AM7/27/11
to ape-p...@googlegroups.com
What system is is? Is it 64 bits?



2011/7/24 Pierre-Olivier <bouteau.pi...@gmail.com>
}

--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to ape-p...@googlegroups.com
To unsubscribe from this group, send email to
ape-project...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Louis Charette

unread,
Aug 14, 2011, 11:11:24 AM8/14/11
to APE Project
Hi,

Have any of you found a solution for this? I have the exact same
problem (Ubuntu 32). I tried the code from the example for mysql and
onConnect never fire.

Thanks,
Louis

On 23 juil, 21:16, JJuN <kjk...@gmail.com> wrote:
>  Hello
>
> I've got another problem inmysql
>
> in serverside script i'm trying to usemysqldemo (http://www.ape-
> project.org/wiki/index.php/Serverside_js_module_using_MySQL)
>
> in this demo i've got a problem with function query
>
> myserver show a error message /var/ape/db/db_test.js 26:TypeError:
> sql.query isnota function

Louis Charette

unread,
Aug 17, 2011, 11:18:36 AM8/17/11
to APE Project
Hi again,

I installed Ape on a new server (Debian 32 bits) and same thing still
happening… Pretty annoying this error :/

Nathan Tran

unread,
Aug 17, 2011, 11:22:13 AM8/17/11
to ape-p...@googlegroups.com
Hi,

You have to download source from Github and compile APE using these instructions:

http://www.ape-project.org/wiki/index.php/Setup#Installing_from_source_or_git

Remember to install all the dependencies especially libmysqlclient-dev .

Nathan.

Nathan Tran

unread,
Aug 17, 2011, 11:24:32 AM8/17/11
to ape-p...@googlegroups.com

Louis Charette

unread,
Aug 17, 2011, 11:26:27 AM8/17/11
to APE Project
I already tried installing from source, but I'm gonna try this branch,
thanks.

On 17 août, 11:24, Nathan Tran <nathant...@gmail.com> wrote:
> Try this branchhttps://github.com/APE-Project/APE_Server/tree/42bcdf8f3dfaf08a1781ca...

Louis Charette

unread,
Aug 17, 2011, 7:09:08 PM8/17/11
to APE Project
I tried the version you gave me. I got some trouble running it (it's
an old version not compatible with "APE_JSF/Tools/Check/"), but in the
end when I try with the "MySQLDemo.js" file, I got this:

../scripts/MySQLDemo.js:7:TypeError: Ape.MySQL is not a constructor

I'll rebuild to make sure I didn't messed up, but… :/

Louis Charette

unread,
Aug 22, 2011, 11:50:28 PM8/22/11
to APE Project
Hi, me again,

I spent some time searching again tonight, just in case. I have a
project I need to start working on next week that need MySQL support.
Otherwise I'll have no choice but to got back to Java Socket or
something like that… But I would really like to use APE, it's seems so
much nice!


Anyway, I double checked my builds and MySQL setting again just to
make sure. But I have a question:

Let's say I put this in the server side code:

var sql = new Ape.MySQL("ip:port", "user", "password", "database");
Ape.log(sql);

What should happen?
Right now I have this in the logs:

2011-08-22 23:34:57 - libape-spidermonkey.c:2475 - JavaScript :
function MySQL() {
[native code]
}

Don't know if it's a good sign or not… It's really annoying not having
any error of callback on this thing. At least I would know where to
start. For now this is all I have since MySQL.onError and
MySQL.onConnect never fire...

Nicolas Guibert

unread,
Aug 23, 2011, 5:05:22 AM8/23/11
to ape-p...@googlegroups.com
Yes, you are right. It is a bit frustrating. I believe, now that there are several people complaining about it, that the APE team will quickly have a look at it. I also need Mysql for my project, and I have to leave my APE server on an old and slow dev environment for the moment (Mysql used to work on this version) because of this, while I'd like to put it on my dedicated server.

Hopefully, this will be resolved soon now.

Regards.

Nicolas.



2011/8/23 Louis Charette <charett...@gmail.com>

Yoann L

unread,
Sep 8, 2011, 6:11:15 PM9/8/11
to APE Project
Hi,

Last build, same problem :(
The sample displayed on the first page of the web page was really
attracting BUT not working...

Hope they'll fix it soon !


On Aug 23, 11:05 am, Nicolas Guibert <ioa.guib...@googlemail.com>
wrote:
> Yes, you are right. It is a bit frustrating. I believe, now that there are
> several people complaining about it, that the APE team will quickly have a
> look at it. I also need Mysql for my project, and I have to leave my APE
> server on an old and slow dev environment for the moment (Mysql used to work
> on this version) because of this, while I'd like to put it on my dedicated
> server.
>
> Hopefully, this will be resolved soon now.
>
> Regards.
>
> Nicolas.
>
> 2011/8/23 Louis Charette <charette.lo...@gmail.com>

Nicolas Guibert

unread,
Sep 8, 2011, 6:35:14 PM9/8/11
to ape-p...@googlegroups.com
Anyone has a guess as to why it does not work anymore?

I don't think they changed anything to Mysql lately, did they?





2011/9/8 Yoann L <yo...@idbrothers.com>

Yoann L

unread,
Sep 9, 2011, 8:39:22 AM9/9/11
to APE Project
Hi again,

I've added some debug in libape-spidermonkey and the error returned by
mysac (from mysql server) is 1045 : Access Denied with all my accounts
even if the password is blank !
I'm using the same accounts in my php scripts.

My version of mysqlclient-dev is 1.6

Nicolas Guibert

unread,
Sep 9, 2011, 9:38:21 AM9/9/11
to ape-p...@googlegroups.com
Does that mean the problem is with mysac and independent of APE?

That could be a bad sign as I have never seen mysac page as very active.

What do you think?



2011/9/9 Yoann L <yo...@idbrothers.com>

Yoann L

unread,
Sep 10, 2011, 3:20:40 AM9/10/11
to APE Project
Many many debugs later...

I've update my sac without problem (rename in makefile mysac_static.a
to my sac_static.a) and every compile like a charm.

The problem is in the implementation of my sac in libeape-
spidermonkey !!!
Look at mysac/example/client which works on my system => The mysac lib
works but not libeape-spidermonkey.

After applying some fix to the libeape-spidermonkey i finally succeed
to connect to my mysql server but i couldn't get ride of the type
error query is not a function !

Even the onConnect does not seem to be called even if JS_CallFunc(...
onConnect...) is called !!!
I think it's a little too buggy for me to use it on our servers in
production !

I'm gonna write my own plugin.

Nicolas

unread,
Sep 10, 2011, 4:18:41 PM9/10/11
to APE Project
Thx very much, this is very much appreciated.

What version of Mysac does APE use? And what version did you use?

I have just received an email from the author of mysac who said that
he had fixed quite a few issues with 64 bits in version 1.0

But you seem to so say that the problem is not with mysac anyway,
right?

Thanks again.

Yoann L

unread,
Sep 11, 2011, 1:37:02 PM9/11/11
to APE Project
I confirm the problem is in libape-spidermonder NOT in mysac (the my
sac works -> example source).

Nicolas

unread,
Sep 12, 2011, 12:00:19 PM9/12/11
to APE Project
Hi,

Did you work with the latest version of mysac or with the beta 0.4b
like APE?

Nicolas.

Yoann L

unread,
Sep 19, 2011, 4:45:05 PM9/19/11
to APE Project

Thx, MySQL works in 1.0.8 !!!

But now, i have some weird problems with pipes...

Do they plan to fix the MySQL issue in 1.2 soon ?

Thx a lot

Nicolas Guibert

unread,
Sep 19, 2011, 4:57:08 PM9/19/11
to ape-p...@googlegroups.com
I have no clue Yoann.

Nicolas.



2011/9/19 Yoann L <yo...@idbrothers.com>

Felix N.

unread,
Dec 8, 2011, 4:41:54 AM12/8/11
to ape-p...@googlegroups.com
I've been trying out everything to get MySQL to work (and I'm completely new to APE and Linux) and finally found a build which seems to work (sql.onConnect is called!!! So it should work!)...

I'm using Debian 6.0 so I installed this http://www.ape-project.org/stable/APE_Server-1.1.1-amd64.deb at first.
Then I compiled 1.2 (https://github.com/APE-Project/APE_Server/tree/1.2) one and replaced aped in /usr/bin/ and libmod_spidermonkey.so in /usr/lib/ape

I hope it helps!! I've been trying things out for about 6 hours now - at first I thought I was doing something wrong...
Reply all
Reply to author
Forward
0 new messages