[OT] Connect to local linux ms access jet database via odbc from php or java
Hi!
I originally sent this post to unixodbc support list but received no
answer. Its crucial to me to solve this problem so any help will be
apreciated.
I spent some time googling and trying to establish connections from linux
pc to local mdb file but had no luck. Here is my configuration:
Ubuntu edgy 2.6.17-10-generic #2 SMP
unixodbc 2.2.11-13
unixodbc-bin 2.2.11-13
libmdbodbc 0.5.99.0.6pre1.0.20051109-3
libmdbtools 0.5.99.0.6pre1.0.20051109-3
mdbtools 0.5.99.0.6pre1.0.20051109-3
mdbtools-gmdb 0.5.99.0.6pre1.0.20051109-3
# cat /etc/odbc.ini
[ODBC]
Trace=yes
Tracefile=/tmp/trc.log
[LOIR]
Description = MicrosoftAccessDatabaseofLOIR
Driver = MDBToolsODBC
Database = /var/www/storage.mdb
Server = localhost
Username = ""
Password = ""
# cat /etc/odbcinst.ini
[MDBToolsODBC]
Description = MDBToolsODBCdrivers
Driver = /usr/lib/libmdbodbc.so.0
UsageCount = 1
FileUsage = 1
# ls -la /var/www
-rw-r--r-- 1 www-data www-data 193 2007-03-25 16:01 .odbc.ini
-rw-r--r-- 1 www-data www-data 48791552 2007-03-24 02:04 storage.mdb
# cat /etc/passwd
www-data:x:33:33:www-data:/var/www:/bin/sh
# cat /var/www/access.php
<html>
<body>
<?php
$conn=odbc_connect('LOIR','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT CITY_NAME, CITY_ZIPCODE FROM CITIES";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table><tr>";
echo "<th>CITY_NAME</th>";
echo "<th>CITY_ZIPCODE</th></tr>";
while (odbc_fetch_row($rs))
{
$compname=odbc_result($rs,"CITY_NAME");
$conname=odbc_result($rs,"CITY_ZIPCODE");
echo "<tr><td>$compname</td>";
echo "<td>$conname</td></tr>";
}
odbc_close($conn);
echo "</table>";
?>
</body>
</html>
phpinfo function returns
odbc
ODBC Support enabled
Active Persistent Links 0
Active Links 0
ODBC library unixODBC
ODBC_INCLUDE -I/usr/include
ODBC_LFLAGS -L/usr/lib
ODBC_LIBS -lodbc
Directive Local Value Master Value
odbc.allow_persistent On On
odbc.check_persistent On On
odbc.default_db no value no value
odbc.default_pw no value no value
odbc.default_user no value no value
odbc.defaultbinmode return as is return as is
odbc.defaultlrl return up to 4096 bytes return up to 4096 bytes
odbc.max_links Unlimited Unlimited
odbc.max_persistent Unlimited Unlimited
When I load page access.php nothing happens. No error just message
"Waiting for localhost..."
I tried with isql and everything is working fine:
# isql LOIR
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select DIN from CITIES
+-----------+
| DIN |
+-----------+
| 1 |
| 112 |
| 126 |
| 130 |
| 151 |
| 160 |
| 163 |
| 181 |
| 185 |
| 222 |
| 258 |
| 331 |
| 1210 |
| 1222 |
| 1245 |
| 1365 |
| 2127 |
| 2185 |
| 2204 |
| 2213 |
| 2218 |
| 2963 |
| 2975 |
| 2977 |
| 2980 |
| 3814 |
| 3822 |
| 4728 |
| 5141 |
| 6323 |
| 6828 |
| 6830 |
| 7187 |
| 7828 |
+-----------+
SQLRowCount returns 34
34 rows fetched
What am I doing wrong?
Is it even possible to connect from php to mdb?
Do I have to buy some drivers?
Is it possible to connect from netbeans to this odbc dns via jdbc-odbc
without some special additional drivers?
Thanks!
--
Mirko Scurk
Reply to: