jtds connection problem.... SQL Server 2012 Express
-
This is my first Java database application so I'm sure I'm missing something. This is the code I have...
import java.sql.*;
public class ClsConn {
private Connection conn;public Connection openConn() { try { System.out.println("Trying the connection now..."); //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class.forName("net.sourceforge.jtds.jdbc.Driver"); //conn = DriverManager.getConnection("jdbc:odbc:IntranetSql"); conn = java.sql.DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433;databaseName=Intranet;user=sa;password=passwrd"); System.out.println("DSN Connection ok."); } catch (Exception e) { System.out.println("DSN Exception: " + e.getMessage()); e.printStackTrace(); } return conn; }
}
This was originally using a DSN, but that didn't seem to work (I was getting some interesting behavior) so I've gone to what you see there. I'm getting this error message: Cannot open database "Intranet" requested by the login. The login failed. For reference on the same server for my asp pages I have the following which is working:
Public Function OpenConnection() As Boolean
Dim connString As String
cnn = New SqlConnection
connString = "server=localhost; uid=sa; pwd=password; database=intranet"
Try
cnn.ConnectionString = connString
cnn.Open()
Return True
Catch ex As SqlException
GlobalClasses.Client_Alert(ex.Message)
Return False
End TryEnd Function
I have opened up 1433 on the server so I have no idea what's going on... Any ideas would be greatly appreciated... --Update 1-- For "fun" I just changed the Database to "Master" and the gosh darn thing "works"... well my query fails because the table it's looking for isn't in Master but the connection is working. I really need to start drinking or something. So it appears that everything is working for for some reason I can't see the database??? --Update 2-- Ok so I change my query figured that would be a good idea right? Nah... So I put in "use Intranet SELECT...." and get "Exception: Database 'Intranet' does not exist. Make sure that the name is entered correctly.". So I did what any good frustrated developer would do and opened up the mgmt studio for SQL Server and went to master and ran the same
-
This is my first Java database application so I'm sure I'm missing something. This is the code I have...
import java.sql.*;
public class ClsConn {
private Connection conn;public Connection openConn() { try { System.out.println("Trying the connection now..."); //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class.forName("net.sourceforge.jtds.jdbc.Driver"); //conn = DriverManager.getConnection("jdbc:odbc:IntranetSql"); conn = java.sql.DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433;databaseName=Intranet;user=sa;password=passwrd"); System.out.println("DSN Connection ok."); } catch (Exception e) { System.out.println("DSN Exception: " + e.getMessage()); e.printStackTrace(); } return conn; }
}
This was originally using a DSN, but that didn't seem to work (I was getting some interesting behavior) so I've gone to what you see there. I'm getting this error message: Cannot open database "Intranet" requested by the login. The login failed. For reference on the same server for my asp pages I have the following which is working:
Public Function OpenConnection() As Boolean
Dim connString As String
cnn = New SqlConnection
connString = "server=localhost; uid=sa; pwd=password; database=intranet"
Try
cnn.ConnectionString = connString
cnn.Open()
Return True
Catch ex As SqlException
GlobalClasses.Client_Alert(ex.Message)
Return False
End TryEnd Function
I have opened up 1433 on the server so I have no idea what's going on... Any ideas would be greatly appreciated... --Update 1-- For "fun" I just changed the Database to "Master" and the gosh darn thing "works"... well my query fails because the table it's looking for isn't in Master but the connection is working. I really need to start drinking or something. So it appears that everything is working for for some reason I can't see the database??? --Update 2-- Ok so I change my query figured that would be a good idea right? Nah... So I put in "use Intranet SELECT...." and get "Exception: Database 'Intranet' does not exist. Make sure that the name is entered correctly.". So I did what any good frustrated developer would do and opened up the mgmt studio for SQL Server and went to master and ran the same
Ok, combo of hatred of M$ and Java here.... apparently when I installed Visual Studio Web edition or IIS it put a copy of SQL Server 2008 Express and Java was nice enough to grab that one vs the 2012 which Visual studio was... Stopped the service for 2008 and now it's working... I'm going to go grab a drink now.
-
This is my first Java database application so I'm sure I'm missing something. This is the code I have...
import java.sql.*;
public class ClsConn {
private Connection conn;public Connection openConn() { try { System.out.println("Trying the connection now..."); //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class.forName("net.sourceforge.jtds.jdbc.Driver"); //conn = DriverManager.getConnection("jdbc:odbc:IntranetSql"); conn = java.sql.DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433;databaseName=Intranet;user=sa;password=passwrd"); System.out.println("DSN Connection ok."); } catch (Exception e) { System.out.println("DSN Exception: " + e.getMessage()); e.printStackTrace(); } return conn; }
}
This was originally using a DSN, but that didn't seem to work (I was getting some interesting behavior) so I've gone to what you see there. I'm getting this error message: Cannot open database "Intranet" requested by the login. The login failed. For reference on the same server for my asp pages I have the following which is working:
Public Function OpenConnection() As Boolean
Dim connString As String
cnn = New SqlConnection
connString = "server=localhost; uid=sa; pwd=password; database=intranet"
Try
cnn.ConnectionString = connString
cnn.Open()
Return True
Catch ex As SqlException
GlobalClasses.Client_Alert(ex.Message)
Return False
End TryEnd Function
I have opened up 1433 on the server so I have no idea what's going on... Any ideas would be greatly appreciated... --Update 1-- For "fun" I just changed the Database to "Master" and the gosh darn thing "works"... well my query fails because the table it's looking for isn't in Master but the connection is working. I really need to start drinking or something. So it appears that everything is working for for some reason I can't see the database??? --Update 2-- Ok so I change my query figured that would be a good idea right? Nah... So I put in "use Intranet SELECT...." and get "Exception: Database 'Intranet' does not exist. Make sure that the name is entered correctly.". So I did what any good frustrated developer would do and opened up the mgmt studio for SQL Server and went to master and ran the same
Hi I have one production issue related to database connection.
Earlier it was a single threaded now other team migrated to Multithreaded application. After migration we have some production related to database connectivity when we perform more operations.
Please find the below logs and hibernate config xml file.
Could some one help me to fix this issue.
Error logs :----
2013-03-01 10:23:53,803 (pool-2-thread-5) [DEBUG] CacheTranscodeManagerImpl - files copied from /opt/transcode/transcode/cache/SN-API-COMCAST_NATIONAL-HD-NC/3DBE3E900937F028BE397C9158CF8510 to /opt/transcode/transcode/output/559311
2013-03-01 10:23:54,449 (pool-2-thread-5) [WARN ] JDBCExceptionReporter - SQL Error: 0, SQLState: null
2013-03-01 10:23:54,449 (pool-2-thread-5) [ERROR] JDBCExceptionReporter - Connection is closed.
2013-03-01 10:23:54,449 (pool-2-thread-5) [ERROR] AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not update: [com.scrippsnetworks.transcode.model.TranscodeCache#248019]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2425)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.springframework.orm.hibernate3.HibernateTemplate$27.doInHibernate(HibernateTemplate.java:801)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:362) -
This is my first Java database application so I'm sure I'm missing something. This is the code I have...
import java.sql.*;
public class ClsConn {
private Connection conn;public Connection openConn() { try { System.out.println("Trying the connection now..."); //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class.forName("net.sourceforge.jtds.jdbc.Driver"); //conn = DriverManager.getConnection("jdbc:odbc:IntranetSql"); conn = java.sql.DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433;databaseName=Intranet;user=sa;password=passwrd"); System.out.println("DSN Connection ok."); } catch (Exception e) { System.out.println("DSN Exception: " + e.getMessage()); e.printStackTrace(); } return conn; }
}
This was originally using a DSN, but that didn't seem to work (I was getting some interesting behavior) so I've gone to what you see there. I'm getting this error message: Cannot open database "Intranet" requested by the login. The login failed. For reference on the same server for my asp pages I have the following which is working:
Public Function OpenConnection() As Boolean
Dim connString As String
cnn = New SqlConnection
connString = "server=localhost; uid=sa; pwd=password; database=intranet"
Try
cnn.ConnectionString = connString
cnn.Open()
Return True
Catch ex As SqlException
GlobalClasses.Client_Alert(ex.Message)
Return False
End TryEnd Function
I have opened up 1433 on the server so I have no idea what's going on... Any ideas would be greatly appreciated... --Update 1-- For "fun" I just changed the Database to "Master" and the gosh darn thing "works"... well my query fails because the table it's looking for isn't in Master but the connection is working. I really need to start drinking or something. So it appears that everything is working for for some reason I can't see the database??? --Update 2-- Ok so I change my query figured that would be a good idea right? Nah... So I put in "use Intranet SELECT...." and get "Exception: Database 'Intranet' does not exist. Make sure that the name is entered correctly.". So I did what any good frustrated developer would do and opened up the mgmt studio for SQL Server and went to master and ran the same
Hello, try specifying the instance parameter in connection string. Following text is extracted from the JTDS FAQ.
SQL Server can run multiple so-called "named instances" (i.e. different server instances, running on different TCP ports) on the same machine. When using Microsoft tools, selecting one of these instances is made by using "<host_name>\<instance_name>" instead of the usual "<host_name>". With jTDS you will have to split the two and use the instance name as a property.
Regards,
Prasad P. Khandekar Knowledge exists, man only discovers it.