Connection refused: connect Error in Java + Hibernate

I am trying to do this tutorial and when I got to the hibernate part, I get this errors: java.sql.SQLException: Network error IOException: Connection refused: connect at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:436) at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataS ource.java:146) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(Wrap perConnectionPoolDataSource.java:195) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(Wrap perConnectionPoolDataSource.java:184) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourceP oolManager.acquireResource(C3P0PooledConnectionPool.java:200) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.ja va:1086) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAc quiresWithinLockOnSuccess(BasicResourcePool.java:1073) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.j ava:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(Basic ResourcePool.java:1810) at […]

Update Column with 2nd Highest Number in SQL

Code: update [MemberBackup].[dbo].[uid3times$] set rc2tobedeleted = case when rc1 > rc2 and rc1 > rc3 and rc2 < rc3 then rc2 when rc2 > rc3 and rc2 > rc1 and rc1 < rc3 then rc1 when rc3 > rc1 and rc3 > rc2 and rc1 < rc2 then rc1 else 0 end I have 3 […]

Getting the application executable name from T-SQL stored procedure

From a stored procedure in SQL Server, is it possible to get the name of the executable (ie MyApp.exe) that owns the connection? I know there is APP_NAME(), but that appears to just return whatever string was passed into the ‘Application Name’ parameter in the connection string. If this is possible, how can it be […]

Microsoft SQL server 2005 query on string: < ' '

I have a Microsoft SQL table tbl with following record: clmn1 (smallint NOT NULL) = ‘2012’ clmn2 (char (10) NOT NULL) = ‘620100’ clmn3 (char (1) NOT NULL) = ” When I execute the query below: select * from tbl with (rowlock) where clmn1 = 2012 and clmn2 = ‘620100’ and clmn3 <= ‘ ‘ […]

SQL Server search using like while ignoring blank spaces

I have a phone column in the database, and the records contain unwanted spaces on the right. I tried to use trim and replace, but it didn’t return the correct results. If I use phone like ‘%2581254%’ it returns customerid ———– 33470 33472 33473 33474 but I need use percent sign or wild card in […]

Fastest/most efficient way to perform this SQL Server 2008 query?

I have a table which contains: -an ID for a financial instrument -the price -the date the price was recorded -the actual time the price was recorded -the source of the price I want to get the index ID, the latest price, price source and the date of this latest price, for each instrument, where […]

tSQL Return first row of partition

The goal is to return the first row of a partition using as little resources as possible. So far, I’ve seen recommendations to use: with customerinfo_CTE as ( select row_number() over(partition by customer order by year desc) as RNumber, * from customerInfo ) select * from customerinfo_CTE where RNumber = 1 So, what I have […]

T-SQL Database Relationships PK FK Same Name?

Scenario I have 3 database tables. One is for Images and the other two are People & Places. Since each person can have many images and each place can have many images, I want to have a ONE TO MANY Relationship between both people and images, as well as places and images. Question Does the […]

SQL Query for retrieving records separated by seconds

I am trying to write a Microsoft SQL Server query for retrieving the oldest record in which the text fields are the same, but the dates are 30 seconds or less apart. Here is an example: My table: RecordID TextField1 TextField2 DateField1 ——————————————————————————– 1 SomeData1 SomeData2 9/11/2011 2:33:00pm 2 SomeData3 SomeData4 9/11/2011 2:33:15pm 3 SomeData3 […]

SQL Server : data updated same row values in all rows while using update command

SQL Server data updated same row values in all rows while using update command. try { SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings[“NORTHWNDConnectionString”].ToString()); myConnection.Open(); foreach (var i in ord) { SqlCommand sqlcm = new SqlCommand(“update Orders Set CustomerID = @CustomerID, EmployeeID = @EmployeeID, ShipVia = @ShipVia, ShipName = @ShipName, ShipAddress = @ShipAddress, ShipCity = @ShipCity, ShipCountry = […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.