RE: Moto drops Mysql connection

"Shay Harding" <sharding-YCNXYxaMkU/[email protected]> Tue, 25 Feb 2003 13:31:07 -0700
Newsgroups gmane.comp.lang.moto.user
Organization CCBill
Message-ID <001401c2dd0c$d31dd950$7500000a@ccbill22ms668m>

> -----Original Message-----
> From: Jack [mailto:[email protected]]=20
> Sent: Tuesday, February 25, 2003 12:57 PM
> To: [email protected]
> Subject: [moto-users] Moto drops Mysql connection
>=20
>=20
> Hi,
> I have this connection code:=20
> ##############################################################
> ###########################################################
> $use("codex.db.mysql")
> $use("codex.util")
> $use("codex.http")
> #readdefs("macro.lib")
>=20
> <html>
>=20
> <body BGCOLOR =3D #FFFFFF TEXT =3D #000000 marginheight=3D"0"=20
> marginwidth=3D"0" topmargin=3D"0" leftmargin=3D"0" =
onLoad=3D"Startup()">
>=20
> ${
> MySQLConnection conn =3D new=20
> MySQLConnection("localhost","db","user","pass");
> String tableName =3D "transactions";
> String query =3D "select * from " + tableName;
> MySQLResultSet rset =3D conn.query(query);
> }$
>=20
> $declare(int cols=3Drset.getColumns())
> $declare(int i)
> $for(i=3D0;i<cols;i++)
> $(rset.getColumnName(i))
> $endfor
>=20
>=20
> Okay, so Im just learning but... ;)
>=20
> In any case this works about 50% of the time, and fails the=20
> other half with this error: Moto Error
>=20
> /var/www/query.moto:15: Uncaught SQLException
>     message: Can't connect to MySQL server on 'localhost' (111)
>=20
> SQLException thrown in=20
> MySQLConnection::MySQLConnection(4)(myconn.c:50)
>    called from function <main>(/var/www/query.moto:15)
>=20
> Now, I thought it was MySQL, but I can connect with=20
> PhpMyAdmin just fine and still not connect with moto.
>=20
> I ran a few of my other php scripts and it all seems to go just fine.
>=20
> The system I am running:
> Linux home 2.4.20-xfs #1 Tue Feb 18 19:00:05 MST 2003 i686=20
> unknown unknown GNU/Linux mysql-server 3.23.55
> apache       1.3.27
> debian testing/unstable 3.0
>=20
> Thanks,
> Jack


Well, I can say for sure that the above works 100% of the time on my
Mandrake 9.0 Linux box running MySQL 3.23.54. The error received is =
coming
right from the MySQL API: "Can't connect to MySQL server on 'localhost'
(111)".

I don't have a Debian box to test this on. I'll try upgrading my =
database to
3.23.55 and see what happens. One note, however, instead of using
"rset.getColumns()", use "rset.columns()". Not sure if the docs are =
updated
yet, but the latter is the most recent API upgrade.

One suggestion is try specifying an IP to connect to rather than
"localhost". This way it will use TCP to connect rather than UNIX domain
socket. This might limit the search for the problem.



Shay




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.456 / Virus Database: 256 - Release Date: 2/18/2003
=20