pavelmed
asked on
SQL Server Express connection error (with Hibernate, Java-based web app, and Tomcat)
I am trying to resolve a database connection problem while trying to setup a Java-based web application.
There is a working Java-based web application (that uses Hibernate and MS SQL Server Express as a database, and Apache Tomcat as a web server).
I am trying to setup a copy of that web site on another computer (for development).
That another computer already has Apache Tomcat and the SQL Server Express installed, and I mad sure that both computers use the same version of Java.
I backed up the database from the working site and restored it on the new machine.
Then I created the war file on the working machine and expanded it on the new machine.
I made sure the database's setup, configuration, and user's login info is identical on both machines. The hibernate.properties files are identical on both machines (except the machine's name).
However the web application fails to be displayed, and Tomcat's log files show the database connection errors.that appear when the Tomcat service is being started, such as
"Login failed for user 'myUser'."
The hibernate.properties file contains these lines:
************************** ********** ********** ********** ********** ********** ********** ********** *
hibernate.connection.url=j dbc:jtds:s qlserver:/ /XXXXXXX1: 1433/musAp p;instance =SQLEXPRES S
hibernate.connection.drive r_class=ne t.sourcefo rge.jtds.j dbc.Driver
hibernate.connection.usern ame=myUser
hibernate.connection.passw ord=myPass word
hibernate.dialect=org.hibe rnate.dial ect.SQLSer verDialect
************************** ********** ********** ********** ********** ********** ********** ********** *******
The errors from the catalina_xxx.log file are below (between the lines):
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
May 28, 2009 12:38:53 PM org.hibernate.connection.C onnectionP roviderFac tory newConnectionProvider
INFO: Initializing connection provider: org.springframework.orm.hi bernate3.L ocalDataSo urceConnec tionProvid er
May 28, 2009 12:38:55 PM org.hibernate.util.JDBCExc eptionRepo rter logExceptions
WARNING: SQL Error: 4060, SQLState: S1000
May 28, 2009 12:38:55 PM org.hibernate.util.JDBCExc eptionRepo rter logExceptions
SEVERE: Cannot open database "musApp" requested by the login. The login failed.
May 28, 2009 12:38:55 PM org.hibernate.util.JDBCExc eptionRepo rter logExceptions
WARNING: SQL Error: 18456, SQLState: 28000
May 28, 2009 12:38:55 PM org.hibernate.util.JDBCExc eptionRepo rter logExceptions
SEVERE: Login failed for user 'musAdmin'.
May 28, 2009 12:38:55 PM org.hibernate.cfg.Settings Factory buildSettings
WARNING: Could not obtain connection metadata
java.sql.SQLException: Cannot open database "musApp" requested by the login. The login failed.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
Could you please assist in resolving the problem?
Again, the application is working on another machine, and the setup is identical (at least, I cannot see the difference).
There is a working Java-based web application (that uses Hibernate and MS SQL Server Express as a database, and Apache Tomcat as a web server).
I am trying to setup a copy of that web site on another computer (for development).
That another computer already has Apache Tomcat and the SQL Server Express installed, and I mad sure that both computers use the same version of Java.
I backed up the database from the working site and restored it on the new machine.
Then I created the war file on the working machine and expanded it on the new machine.
I made sure the database's setup, configuration, and user's login info is identical on both machines. The hibernate.properties files are identical on both machines (except the machine's name).
However the web application fails to be displayed, and Tomcat's log files show the database connection errors.that appear when the Tomcat service is being started, such as
"Login failed for user 'myUser'."
The hibernate.properties file contains these lines:
**************************
hibernate.connection.url=j
hibernate.connection.drive
hibernate.connection.usern
hibernate.connection.passw
hibernate.dialect=org.hibe
**************************
The errors from the catalina_xxx.log file are below (between the lines):
--------------------------
May 28, 2009 12:38:53 PM org.hibernate.connection.C
INFO: Initializing connection provider: org.springframework.orm.hi
May 28, 2009 12:38:55 PM org.hibernate.util.JDBCExc
WARNING: SQL Error: 4060, SQLState: S1000
May 28, 2009 12:38:55 PM org.hibernate.util.JDBCExc
SEVERE: Cannot open database "musApp" requested by the login. The login failed.
May 28, 2009 12:38:55 PM org.hibernate.util.JDBCExc
WARNING: SQL Error: 18456, SQLState: 28000
May 28, 2009 12:38:55 PM org.hibernate.util.JDBCExc
SEVERE: Login failed for user 'musAdmin'.
May 28, 2009 12:38:55 PM org.hibernate.cfg.Settings
WARNING: Could not obtain connection metadata
java.sql.SQLException: Cannot open database "musApp" requested by the login. The login failed.
--------------------------
Could you please assist in resolving the problem?
Again, the application is working on another machine, and the setup is identical (at least, I cannot see the difference).
Can you telnet to that address and port from the machine you're trying to run it on?
ASKER
I am trying to access the site locally, from the same machine.
I can use the working site also locally, from the working machine.
Both machines are development machines.
On the new machine, if I try to display the web site, it is starting but fails when it tries to use DB data.
I don't have telnet on that machine.
I can use the working site also locally, from the working machine.
Both machines are development machines.
On the new machine, if I try to display the web site, it is starting but fails when it tries to use DB data.
I don't have telnet on that machine.
I don't know about SQLEXPRESS but on standard SQL Server, I have a similar Hibernate config, but I always have to enable the SQL Server TCP port first. I use "SQL Server Configuration Manager" from the start menu and under SQL Server Network Configuration, enable TCP/IP, then set Listen all and IPall to port 1433
MySql must have granted permissions to connect from the host (machine) you're currently connecting from.
http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
Oops sorry - wrong DB!. Nonetheless, make sure you have permission to connect from that host
ASKER
I set it up exactly as on working machine: under SQL Server Network Configuration, enabled TCP/IP, and also enalbed TCP/IP under SQL Native Client Configuration.
1433 port is specified under SQL Native Client Configuration.- it is setup that way and works on another machine,
1433 port is specified under SQL Native Client Configuration.- it is setup that way and works on another machine,
Your sqljdbc.jar (or whatever the source fource driver jar name is) is deployed with your web app or is it in Tomcat common lib?
It doesn't look like a missing jar, it looks like a permissions problems, but since I don't use that driver, I use the standard Microsoft one, I cannot say.
It doesn't look like a missing jar, it looks like a permissions problems, but since I don't use that driver, I use the standard Microsoft one, I cannot say.
ASKER
CEHJ, the user is setup as a database owner on that machine.
However, I would like to test a DB connection.
How can I test a DB connection? The tool that I am using, the SQL Server Management Studio Express, uses a Windows authentication, so username and password are not needed to connect to the database
However, I would like to test a DB connection.
How can I test a DB connection? The tool that I am using, the SQL Server Management Studio Express, uses a Windows authentication, so username and password are not needed to connect to the database
ASKER
mrjoltcola, I am not sure about that driver. it users the net.sourceforge.jtds.jdbc. Driver. In catalina.log file I can see that tomcat loads the file.
ASKER
I have resolved this error.
Administrator, please close this question.
Administrator, please close this question.
Can you provide the solution for our benefit? :)
You normally close your own questions by either deleting or scoring a solution. If you found your own solution, it is good for EE if you post it and score it, and also helps the experts that spent time trying to assist you, for future knowledge purpose.
You normally close your own questions by either deleting or scoring a solution. If you found your own solution, it is good for EE if you post it and score it, and also helps the experts that spent time trying to assist you, for future knowledge purpose.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER