Support Requests item #429141, was updated on 2001-05-31 13:48
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=203152&aid=429141&group_id=3152
Category: Configuration: Database
Group: aolserver3_4
>Status: Closed
Priority: 5
Submitted By: Tyge Cawthon (tyge)
Assigned to: Dossy Shiobara (dossy)
Summary: help w/data from AOL into Postgresql
Initial Comment:
I have done a lot of reading and I am stuck.
I would appreciate any help.
I am using FreeBSD 4.3, AOL 3.4 and postgreSQL all on
the same system.
I have created a database called tyge a table called
customer and a field called name.
I started postgresql with the postmaster -i option.
This is the default Host: localhost Port:5432
I can use the SQL commands to insert data into the
"name" field", but when I try using HTML, ADP (TCL)
with AOL I get the following error message.
[31/May/2001:15:27:39][3282.135895040][-conn4-] Error:
command "ns_db" is not enabled
while executing
"ns_db gethandle"
invoked from within chunk: 0 of adp:
/usr/local/aolserver/servers/server1/pages/tygedb.adp
my config.tcl use by my AOL server is the default setup
with the exception of the commands below.
# What is needed for connecting to a data base
# Added by Tyge Cawthon 5/14/01
#
ns_section "ns/server/server1/db"
ns_param pools *
ns_section "ns/db/drivers"
ns_param postgres nspostgres.so
# ns_param solid nssolid.so
ns_section "ns/db/pools"
ns_param mypool "The Default Database Pool"
# ns_param otherdb "The Other Database Pool"
ns_section "ns/db/pool/mypool"
ns_param driver postgres
ns_param connections 2
ns_param datasource "localhost:5432:tyge"
ns_param LogSQLErrors on
# ns_section "ns/db/pool/otherdb"
# ns_param driver solid
# ns_param connections 4
# ns_param datasource "TCP/IP hostname 1313"
#
ns_section "ns/server/server1/modules"
ns_param nscp nscp.so
ns_section "ns/server/server1/module/nscp"
ns_param port 9999
ns_param address 127.0.0.1
ns_param binary bin/nscp
#
# Tyge's statements end here
tygedb.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Customer Input Form</title>
<meta http-equiv="Content-Type" content="text/html">
</head>
<body>
<h2>Customer Information</h2>
<form method="post" action="tygedb.adp" />
<p>
First Name <input type="text" size="30" name="name">
</p>
<p>
<input type="submit" value="Submit">
</p>
</form>
</body>
</html>
tygedb.adp
<HTML>
<HEAD>
<TITLE>Customer Input Information</TITLE>
</HEAD>
<BODY>
<H2>
Testing inputting customer information
</H2>
<P>
Thank You for testing!
<%
# Get form data and assign to variables
set r [ns_conn form $conn]
set name [ns_set get $r name]
# Update database with new subscription
set db [ns_db gethandle]
# ns_db dml $db \
ns_db dml tyge \
"insert into customer values ([ns_dbquotevalue $name])"
\
%>
</BODY>
</HTML>
----------------------------------------------------------------------
>Comment By: Dossy Shiobara (dossy)
Date: 2001-06-03 19:01
Message:
Logged In: YES
user_id=21885
Cool! Glad you were able to get everything up and running,
finally!
Whatever notes you have, feel free to attach them to this
ticket. If the same questions come up again, I'll simply
refer people back to this ticket.
On the peer rating, 0 is lowest, 6 is highest.
If you have any other issues, feel free to open a new
ticket! -- Dossy
----------------------------------------------------------------------
Comment By: Tyge Cawthon (tyge)
Date: 2001-06-03 17:48
Message:
Logged In: YES
user_id=217624
Dossy, IT WORKS!!!! THANK A LOT!!!
I also found out that we can not have comment lines inside
like line 19. With the commented line in, I would get an
error message. I would like to offer (when I get done) the
notes I have been taking for other people like myself who
are learning this. Let me know if you would like them or
where I can post them for all to see. THANKS AGAIN....
I would like to give you highest ranking as possible for
support. Which number is the highest 1 or 6. I do not
understand the manes.
P.S. I think we can close out this ticket......Please let me
know if YOU need anything.
----------------------------------------------------------------------
Comment By: Dossy Shiobara (dossy)
Date: 2001-06-03 17:24
Message:
Logged In: YES
user_id=21885
I see a problem with the code tygedb.adp:
18 set db [ns_db gethandle mypool]
19 # ns_db dml $db \
20 ns_db dml tyge \
21 "insert into customer values ([ns_dbquotevalue
$name])"
22
23 \
First off, what's the point of line 23? Just delete it.
Secondly, [ns_db dml] takes two args, the first is a
dbhandle and the second is the sql. The dbhandle is not
the pool name, it's what gets returned from [ns_db
gethandle]. So, the line you had commented out on line 19
is correct. Delete line 20 and uncomment line 19.
Hope this solves your problem. -- Dossy
----------------------------------------------------------------------
Comment By: Tyge Cawthon (tyge)
Date: 2001-06-03 14:29
Message:
Logged In: YES
user_id=217624
Dossy, I have made the requested changes to aol-config.tcl.
Stopped and restarted the process. No changes in the
server.log file. I uncomment the ns_paran LogSQLErrors and
added below that line the ns_param verbose on.
ns_section "ns/db/pool/mypool"
ns_param driver postgres
ns_param connections 2
ns_param datasource localhost:5432:tyge
ns_param LogSQLErrors on
ns_param verbose on
Is this where the verbose command should be?
----------------------------------------------------------------------
Comment By: Dossy Shiobara (dossy)
Date: 2001-06-03 07:55
Message:
Logged In: YES
user_id=21885
Looks as though the last change to your config. at least
got the driver loaded, as seen in the server.log:
[03/Jun/2001:09:34:04][12625.135540736][-main-] Notice:
modload: loading '/usr/local/aolserver/bin/nspostgres.so'
[03/Jun/2001:09:34:04][12625.135540736][-main-] Notice:
nspostgres: loaded 'PostgreSQL'
Line 246 is unnecessary. You define database drivers in
section ns/db/drivers, not in ns/server/
${servername}/modules.
Looking at your server.log further, I see:
[03/Jun/2001:09:34:47][12625.135913472][-conn0-] Notice:
dbdrv: opening database 'postgres:localhost:5432:tyge'
[03/Jun/2001:09:34:47][12625.135913472][-conn0-] Notice:
nspostgres: opening 'tyge' on 'localhost'
[03/Jun/2001:09:34:47][12625.135913472][-conn0-] Notice:
nspostgres: opened connection to 'localhost:5432:tyge'
It's not telling you very much, like whether or not the
connection to the database successful. I suggest setting
verbose on and hope that the nspostgres driver spits out
some diagnostic output. You can do this by inserting on
line 233:
ns_param verbose on
You may also want to uncomment the ns_param LogSQLErrors
line, as well.
But, you're right -- at this point, it looks like a Tcl/ADP
problem. Let me know this solves your problems. -- Dossy
----------------------------------------------------------------------
Comment By: Tyge Cawthon (tyge)
Date: 2001-06-03 07:43
Message:
Logged In: YES
user_id=217624
GOOD NEWS... As you can see by the log file there are no
error messages. I have attached the lastest log file and
aol-config.tcl.
I think the problem is now with the html and ADP.
I will look into this later today. Meanwhile your
suggestion have been very much appreicated.
----------------------------------------------------------------------
Comment By: Dossy Shiobara (dossy)
Date: 2001-06-02 19:56
Message:
Logged In: YES
user_id=21885
Move lines 212--214 down to right before the
ns/server/server1/modules section. You're
You need to define your db pools before
referring to them in a particular server's
config.
212 ns_section "ns/server/server1/db"
213 # ns_param pools *
214 ns_param DefaultPool mypool
Also, uncomment line 213.
Try this out, and let me know if you have any
luck. Also, what command line are you using to
start AOLserver? It doesn't even seem as though
you're using the aol-config.tcl that you uploaded,
as nowhere in the log is it even mentioning that
it's trying to load /usr/local/aolserver/bin/nspostgres.so
which seems kind of strange to me.
-- Dossy
----------------------------------------------------------------------
Comment By: Tyge Cawthon (tyge)
Date: 2001-06-02 18:42
Message:
Logged In: YES
user_id=217624
Dossy, I have just installed
/usr/local/aolserver/bin/nspostgres.so
I stop the process and restarted. The log fileslooks the
same as before. I attahced the new serverlog file.
I think now it is my setup. I am not sure what this message
means.
Error: dbinit: no such default pool 'mypool'
----------------------------------------------------------------------
Comment By: Dossy Shiobara (dossy)
Date: 2001-06-01 20:17
Message:
Logged In: YES
user_id=21885
Ah, that would be your problem! Yes, you need to go get
the nspostgres driver, compile it, and put it in your bin/
directory. As I recall, the nspostgres driver on the
aolserver.com site is out of date, and people have been
told to get it from the Postgres site somewhere. Perhaps
someone else will give a more specific pointer to where the
latest driver is available. If you have trouble locating
the driver, let me know and I'll find it. -- Dossy
----------------------------------------------------------------------
Comment By: Tyge Cawthon (tyge)
Date: 2001-06-01 18:52
Message:
Logged In: YES
user_id=217624
dossy, Should there be a file or directory somewhere under
the aolserver directory called nspostgres.so? That may be
my problem. I can not find such a file or directory.
----------------------------------------------------------------------
Comment By: Dossy Shiobara (dossy)
Date: 2001-06-01 17:26
Message:
Logged In: YES
user_id=21885
I've just reviewed the server.log you've uploaded, and I
don't see anywhere that it's even trying to load
nspostgres.so -- there must be a problem with your
config.tcl. Could you please supply the entire config.tcl
as-is (attach it to this ticket)? Thanks. -- Dossy
----------------------------------------------------------------------
Comment By: Dossy Shiobara (dossy)
Date: 2001-06-01 14:56
Message:
Logged In: YES
user_id=21885
Please stop nsd, remove your log/server.log, and start nsd
again. Then, reproduce the error. Then, stop nsd, then
attach your log/server.log to this support ticket. -- Dossy
----------------------------------------------------------------------
Comment By: Tyge Cawthon (tyge)
Date: 2001-06-01 14:44
Message:
Logged In: YES
user_id=217624
Dossy, thanks for the fast response. I have tried your
suggestion. I first changed the config.tcl adding the line
ns_param DefaultPool mypool. I stopped and restarted AOL.
Same problem. Next I modified tygedb.adp with ns_db
gethandle mypool. The error message change to report
command "ns_db" is not enabled
while executing
"ns_db gethandle mypool" This is a good start. At least we
know it is looking from mypool.
The last thing I changed was that I took off the quotes
signs in the config.tcl file on the line
ns_param datasource localhost:5432:tyge was
ns_param datasource "localhost:5432:tyge"
It's got to be something simple I am missing.
I do not fully understanding how the config.tcl file works.
I think this is where the problem may be. Once again,
thanks.
P.S. I am tracking and documenting is for other users.
----------------------------------------------------------------------
Comment By: Dossy Shiobara (dossy)
Date: 2001-05-31 17:41
Message:
Logged In: YES
user_id=21885
[ns_db gethandle] is complaining because you aren't
specifying which db pool to get a handle from. You
have two options:
1) Change [ns_db gethandle] to [ns_db gethandle mypool]
or
2) Add the following to your ns/server/server1/db section:
ns_param DefaultPool mypool
The DefaultPool is the pool from which [ns_db gethandle]
will fetch a handle if the pool isn't specified.
Does this solve your problem? -- Dossy
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=203152&aid=429141&group_id=3152