Hello Petr,
Well you did give me some hints that helped me a lot! I solved the
problem late last night. It was one of the very nasty bitches....
It was as I assumed at the very beginning: If I debug my environment
inside Eclipse it is not the same as running a deployed version in a
Tomcat deamon or service. I must say, that I spent $ 35.-- to buy a
license of MyEclipse Workbench, a plugin to support J2EE developments on
all important free and commercial J2EE containers. So with this plugin,
J2EE development may behave slightly different from standard Eclipse.
Using MyEclipse you have to configure every J2EE container you like to
run your application with separately. Configuring means: setting the
classpath and the librarypath.
Since ASA uses a level 3 driver it needs to load the DLL at some point
using a call to loadLibrary(). There you have to pass either the name of
the library/DLL or a fully qualified path. If you only pass the name, it
must be found in your system path. Normal java behaviour is to load your
system environment into System.property. The ODBC driver needs to be
somewhere in your PATH. The entire path goes into a system property
called 'java.library.path'. When starting my app from within eclipse,
the library path contained only Tomcat (which is my J2EE container /
servlet engine). The environement of my PC is stored in the Eclipse Java
Process but NOT inherited to TOMCAT!!! So I added the path where the
ODBC DLL is located to the J2EE Container configuration and everything
worked fine!! To find that out I needed to install the Tomcat Source and
debug it. The exception thrown from the iAnywhere driver was saying
something like 'dbodbc9 not found in java.library.path'. This message
was finaly the hint which let me find the problem late last night.
Regarding ASA, Internationalisation etc.
T-SQL is fine, I have written thousands of stored procedures using it.
But it has certain limitations which do not exist in the ASA SQL
language. The VERY nice thing of ASA is, that you can use both dialects,
so you can have procedures written in T-SQL and others in ANSI / WATCOM
SQL. It is also possible to develop an application for ASE or MS SQL on
ASA. Porting it is quite easy. We use ASA for lots of purposes,
currently we are developing mobile applications using all the
distributed and synchronisation features of the ASA middleware. Great
stuff! We soon publish an application that allows synchronisation
between PDA's, Mobile Phones and Central Databases using ASA as
middleware. The central databases could be any Database such as Sybase,
Oracle, DB2, Microsoft or whatever. Also a nice feature of ASA is the
built-in Web server. You can run web applications directly off your
database server by writing so called 'Web Services'.
Regarding internationalisation ASA will currently not help you very
much. But later this year (I assume Q3 or Q4) ASA 10 will come out. This
version will have native support for UNICODE inside the database and
better support for internationalisation. I have no more details yet. It
also will support database clustering and many more features. Since we
are one of the leading OEM and system integration partners from
SYBASE/iAnywhere for ASA in Switzerland, we will receive a beta copy,
once it comes out. It was announced for Q1/2006, but I haven't gotten
anything yet! But as developers we all know, it usually takes a bit
longer than expected!
Regards
Thomas
Hadraba Petr wrote:
Hello Thomas,
thank you for your informations! I will order ASA developer edition
and learn new database;-) Now, I'm looking for a database which
provides internationalization features; specially ORDER BY [(var)char
| text] column and I have no success:
ASE and localization -- it's a workaround.
PostgreSQL -- it's the same. You must define locale during database
storage creation:-(
Firebird -- currently I have no experience:-(
Oracle -- expensive:-(
So, maybe ASA will solve my problem
Regarding T-SQL: I don't know how you, but I find T-SQL great... Some
constructions are interesting
Regarding JDBC: Maybe the native library causes your problems. I'm
using only pure-Java drivers located in the common/lib with no
problems.
Regarding DBCP: I found DBCP classes in the stack traces during my
driver's debugging. And finally -- there is naming-factory-dbcp.jar in
the common/lib...
Regarding Tomcat and data sources: I found this more then obscure. I
have one question: If you write a webapp which uses database; where
shall I define the datasource names? Hardwiring is not a solution. And
put them (the definitions) into some configuration file into the
webapp war file?? Ofcourse, Tomcat have the admin app in which you can
define app-specific database cources... But Sun Java System App server
not... There are in the SJSAS only global resources... I must learn
more...
So, many many thanks for your informations; I'm sorry that I didn't help you:-(
Have a nice day
PETR
On 3/6/06, Tom Bednarz <[EMAIL PROTECTED]> wrote:
Hi Petr,
Thanks for your feedback. It still does not work for me, no matter where
I put the damn JAR file. So I will use my own pooling class directly in
my webapp based on Apaches DBCP which is part of Jakarta Commons. It is
probably faster then fiddeling with this bloody driver configuaration.
I currently should use the pool from JSP's and not from Java code.
However, it should not make a difference.
Just for your information regarding ASA and ASE: ASA is a database
originally written by a company called WATCOM in Canada. I use the
software for more then 10 years and it is one of the best DB engines
money can buy. Even with large databases (several GB in size) it is
faster then MS SQL Server. ASE is only faster if there are hundreds of
concurrent users, but ASE has still many limitations in SQL syntax, db
space management, datatypes etc. Also it only understands T-SQL while
ASA understands both T-SQL and ANSI SQL.
Regarding JDBC: jConnect is a driver provided from SYBASE. It works on
ASE as well as on ASA and uses the Tabular Data Stream TDS protocol.
jConnect is quite slow and does NOT support scrollable cursors, but it
is a pure java, level 4 driver. JDBCODBC.IDriver is a NATIVE library
driver (level 3). It is NOT using bridge, it is using a native DLL or
.SO on UNIX. To connect one needs to setup a ODBC datasource which may
be painful, if you have to redistribute a client. (You need to integrate
the entire ODBC stuff in your setup program). This driver is relatively
new (compared to jConnect) and was introduced with ASA 8 (I think).
Currently we have ASA 9.x. Earlier version only could use jConnect.
Cheers
Thomas
Hadraba Petr wrote:
Hi,
I studied something about Sybase ASA and here are my pieces of knowledge:
- ASA is, unlike ASE, ODBC based insted of TDS
- the JDBC drivers are generic JDBC-to-ODBC bridge and can be used to
access _any_ database throw ODBC
- the JDBC drivers are not freely downloadable (I didn't find any)
- You can access ASA also throw jConnect (TDS based Sybase's JDBC drivers)
This solution is functional but the speed (power) is less -- Sybase
does not recomand to use jConnect drivers.
So, I tried to use my ASE under Tomcat (Currently, I'm successfuly
using PostgreSQL). The following solution works fine under Tomcat
standalone and Tomcat under Eclipse.
Small HOWTO for Tomcat 5.5.15/jdk1.5.0_06/Linux:
1. Locate your existing JDBC driver, or try use jConnect
(http://www.sybase.com/products/middleware/jconnectforjdbc)
2. Copy the driver jar(s) into ${CATALINA_HOME}/common/lib
3. Create your META-INF/context.xml
4. Make the resource references in the WEB-INF/web.xml
5. Use the data source(s) in your code
I saw the `Cannot load JDBC driver class' and it seens the drivers
must be in the common/lib directory.
Finally, here is my context.xml, web.xml and example lines using the database
Hope this helps
PETR
META-INF/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource
auth="Container"
scope="Shareable"
description="Logging database connection"
name="jdbc/project/logger"
type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://127.0.0.1:5432/project"
username="uname"
password="password6"
maxIdle="20"
maxWait="5000"
maxActive="20"
validationQuery="SELECT version();" />
<Resource
auth="Container"
scope="Shareable"
description="Test connection to the Sybase ASE server"
name="jdbc/project/sybase"
type="javax.sql.DataSource"
driverClassName="com.sybase.jdbc3.jdbc.SybDriver"
url="jdbc:sybase:Tds:ws:5000"
username="sa"
password=""
maxIdle="20"
maxWait="5000"
maxActive="20"
validationQuery="" />
</Context>
WEB-INF/web.xml
...
<resource-ref>
<description>PROJECT client</description>
<res-ref-name>jdbc/project/logger</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<description>PROJECT client</description>
<res-ref-name>jdbc/project/sybase</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
SAMPLE/code
...
final Context initCtx = new InitialContext();
final Context envCtx = (Context)
initCtx.lookup("java:comp/env");
final DataSource dataSource = (DataSource)
envCtx.lookup(databaseName);
final Connection conn = dataSource.getConnection();
final PreparedStatement stmt = conn.prepareStatement(
"INSERT INTO access_log (acsl_account,
acsl_object) " +
"VALUES (NULL, ?)");
final HttpServletRequest request =
getContentManager().getRequest();
final String log = request.getRequestURL().toString() +
" -- " + request.getRemoteHost() + ":" +
request.getRemotePort() +
" -- " + parseRequestHeaders(request);
stmt.setString(1, log);
stmt.execute();
stmt.close();
conn.close();
//
final DataSource ds = (DataSource)
envCtx.lookup("jdbc/project/sybase");
final Connection cn = ds.getConnection();
Statement st2 = cn.createStatement();
st2.execute("USE test");
st2.close();
cn.close();
On 3/3/06, Tom Bednarz <[EMAIL PROTECTED]> wrote:
Hi,
Thanks for your help. It brought me one step further but did not yet
solve the problem! It looks like the context.xml is mandatory. I moved
the configuration from the server.xml to the context.xml. The error
message changed as follows:
org.apache.jasper.JasperException: Unable to get connection, DataSource invalid:
"org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class
'ianywhere.ml.jdbcodbc.IDriver'"
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
This means it does not find the driver jar file. I put it in all
possible directories (lib directories of the webapp, tomcats common/lib
and shared/lib) but all without success. Do I have to set a CLASSPATH
somewhere??
Tom
Hadraba Petr wrote:
Hi,
I'm not using Sybase under Tomcat; I have PostgreSQL...
Eclipse? My configuration is, Eclipse does not modify Tomcat
configuration (this is the default)
In your WebContent under META-INF create context.xml with the
<Resource ... /> definition. The <Context /> element does not require
any attributes:
<Context>
<Resource ... your="attributes" ... />
</Context>
And finaly, place the JDBC driver JAR into your WEB-INF lib.
Catalina will automaticaly load your driver. My configuration is
working properly.
This configuration is working for me fine!
JNDI names? Look at the JNDI section in the J2EE Tutorial in the Sun's
web site. The examples are very helpful.
There is also another question:
It's good solution to place JDBC driver into the webapp's lib directory?
Hope it helps
PETR
PS.: My Adaptive Server Enterprise 15 is working good, but not under
Tomcat; it's standalone application... The initialization, driver URL
was taken from the Sybase's JDBC documentation on their web sites.
On 3/3/06, Tom Bednarz <[EMAIL PROTECTED]> wrote:
I try to configure a JDBC DataSource for my Adaptive Server Anywhere 9
database. Unfortunately without any success so far!
I use Tomcat 5.5.18.
The error is well known and looks as follows:
org.apache.jasper.JasperException: Unable to get connection, DataSource
invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
JDBC driver of class '' for connect URL 'null'"
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I use the JDBCODBC driver to connect. Here is the configuration:
server.xml
<Resource
name="jdbc/MyService"
type="javax.sql.DataSource"
password="sql"
driverClassName="ianywhere.ml.jdbcodbc.IDriver"
maxIdle="2"
maxWait="5000"
validationQuery="select * from CodeTable"
username="dba"
url="jdbc:odbc:dsn=MyService"
maxActive="50"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"/>
Web.xml
<resource-ref>
<description>Database connection</description>
<res-ref-name>jdbc/MyService</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Note: I currently do NOT deplay using a WAR file since I use Eclipse as
develpment environment to debug etc. So I do NOT have an application
specific context.xml file at the moment.
Could anybody please explain what needs to be put into the name
property? It seems that jdbc/ is mandatory but what needs to follow the
slash is not clear to me! Is it the ODBC datasource name, the database
name or any choosen name??
Many thanks for your help.
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]