Moto interface to MySQL
Jack <[email protected]> 05 Mar 2003 20:14:26 -0700
| Newsgroups | gmane.comp.lang.moto.devel,gmane.comp.lang.moto.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm trying to set up a web site which interfaces to a database.
Okay here is my source with the necessary changes to protect the
innocent ;).
<body BGCOLOR = #FFFFFF TEXT = #000000 marginheight="0" marginwidth="0"
topmargin="0" leftmargin="0" onLoad="Startup()">
$if(getValue("begin_month") == null) OOps, no begin_month $endif
$if(getValue("end_month") == null) OOps, no end_month $endif
$if(getValue("begin_day") == null) OOps, no begin_day $endif
$if(getValue("end_day") == null) OOps, no end_day $endif
$if(getValue("begin_year") == null) OOps, begin_year $endif
$declare(String begin_day = (getValue("begin_day")))
$declare(String begin_month = (getValue("begin_month")))
$declare(String begin_year = (getValue("begin_year")))
$declare(String end_day = (getValue("end_day")))
$declare(String end_month = (getValue("end_month")))
$declare(String end_year = (getValue("begin_year")))
$declare(String begin_date)
$do(begin_date=begin_year+begin_month+begin_day)
$declare(String end_date)
$do(end_date=end_year+end_month+end_day)
$declare(String queryType= (getValue("querytype")))
${
MySQLConnection conn = new
MySQLConnection("localhost","c4_webapp","user","pass");
String tableName = "transactions ";
String fields = "date,picture,description ";
String compareField = "date";
String query="SELECT " +
fields +
"FROM " +
tableName +
"WHERE " +
"type = '"+
queryType +
"' AND "+
compareField +
">="+
begin_date +
" AND " +
compareField +
"<"+
end_date;
MySQLResultSet rset = conn.query(query);
int cols=rset.getColumns();
int i=0;
int j=0;
}$
Okay, fine it works great on my local machine - runs as expected.
When I upload this to the server, it would seem that moto takes
localhost to mean ME... the client on my side of the browser.
Contrast this with PHP, where localhost is the server.
In anycase, it tries access the data on my home server and everything
again works, but if I access from a windows machine an error occurs.
If I replace the name localhost with either the server IP or the
domainname, I end up getting this error:
/var/www/site/query.moto:27: Uncaught SQLException
message: Host 'deer.cyberport.net' is not allowed to connect to this MySQL server
SQLException thrown in MySQLConnection::MySQLConnection(4)(myconn.c:50)
called from function <main>(/var/www/site/query.moto:27)
deer.cyberport.net is me through my dsl.
So what am I doing wrong here?
Any help is appreciated.
Thanks,
Jack