Jump to content
Excelsior Forums
littlefish

Can I ODBC to Database fm NT Service?

Recommended Posts

I use the sample code "Simple Services" and insert the following codes. Although the codes are working in normal java application, it does not connect to the database and report errors in NT service.

Insert to line #1, "import java.sql.*;"

Insert to line #11, "public Connection dbConn;"

Insert to line # 33, just below "// working ..."

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

dbConn = DriverManager.getConnection("JDBC:ODBC:TESTODBC","testuser","111");

}

catch (Exception e)

{

logErrorEvent("Error : \n" + e.toString());

}

Does Excelsior NT service not support database connection? or is this a bug?

Share this post


Link to post
Share on other sites

Hello.

The jdbc do not work in your sample because it probably uses dynamic lookup of classes. JET was unable to find the JET RT dlls due to invalid PATH setting for NT service.

The environment for NT service is hard to set, so there is another way to overcome this problem.

First solution is to place JET RT dlls (located at JET\BIN) and NT service exe into the same direcory. Restart NT service, it should behave properly now. This solution is appropriate for development and testing.

Second solution is to use JetPackII to create a distributive for your NT service and install it. The installed JET-compiled applications (and NT services) do not require PATH setting at all.

Hope it helps.

-AlexM.

Share this post


Link to post
Share on other sites

I copy all DLLs (ie, *.DLL) from \JET\BIN directory and run the sampleservice.java again, same error comes out.

Do you mean EVERYTHING from \JET\BIN directory?

Pls double-confirm your last advice.

Share this post


Link to post
Share on other sites

Actually, after the failure of just copying the *.dll, I have tried again by copying everything from JET\BIN into the directory of the generated exe file.

Same error, no improvement.

Share this post


Link to post
Share on other sites

Error description from W2000 Event Viewer

Error (1003) :

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Share this post


Link to post
Share on other sites

Maybe the data source and/or ODBC driver is configured to be available for specific users.

Note that you have to specify user name and password for NT service (during installation or from the services in the control panel) otherwise it will run using localsystem account which has the full access to the local computer but unable to access network and other resources that require user authentication.

So you may try to set proper user name and password for NT service and for data source.

-AlexM

Share this post


Link to post
Share on other sites

I cannot agree.

I am using English W2000+SP3, SQL2000+SP2

Everything on a single machine, not networking

I log on as Administrator

I have created a testing ODBC, testing user and testing user password, etc.

My development has been done over 6 months using the above setting.

I have also created a testing Java application will the same ODBC setting and same user ID and same password. The Java application has also been compiled with standard JET3.00 (purchased in Feb'2003). It works fine.

When I try to compile a testing apps using your sample "SimpleSample" with added testing codes (mentioned in my first msg), it reports error.

I try to follow your advice by installing the latest JET311, the same error comes out.

The account setting in the W2K service is NOT the same as ODBC user name and password (as far as I know).

Unless JET is using it, isn't it???

Anyway, I think this is a critical BUG.

My customer is started to show dissappointed.

If I am willing to PAY immediately by upgrading to the JET311 Professional Edition with Premium support, please advise your agreement of support level, service quality and response time.

Moreover, pls confirm that this BUG will be fixed.

Share this post


Link to post
Share on other sites

The NT service is NOT running in the current account you logged on. You should specify the account for the service in the isrv command line or using the services applet in the control panel. Otherwise it uses special account which do not allow to connect to SQL Server.

I log on as Administrator

So you should specify the same (Administrator) account for the NT service.

You haven't come across a bug.

It is a misunderstanding of the environment the NT services run in.

-AlexM.

Share this post


Link to post
Share on other sites

×