Tag: java

Hibernate: On SQL Server 2008 column was altered from datetime to datetime2. How I can update hibernate config to reflect this?

I have an application in which I created mappings of entities in Hibernate, so I could have access to some legacy tables on SQL Server 2005. Everything was working fine and as expected until the database was switched to a newer version of SQL Server – specifically, to SQL Server 2008. As the data were […]

Cannot connect to MSSQL due to Login-based server access validation failed with an infrastructure error

I have an application (web application) written in Java and database on MS SQL. Both, Tomcat (with application) and database server are on my localhost. I’m trying run an application but in Java logs I have: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Login failed for user ‘some-user’.) Caused by: java.sql.SQLException: Login failed for user ‘some-user’. In database […]

SQL Server 2008 datetime column JDBC insert problem

I have a table with a column that is a DATETIME in a SQL Server 2008 database. The dates that are being inserted are not timestamps in the sense that using NOW on insert would be acceptable. The date is generated a bit before the insert and I would like to preserve this value. Datetimes […]

Find SQL Servers using Java

This might be a basic question, but I tried googling it and couldn’t find an answer. I need to make a list of all the SQL Servers on a network. This is very easy to do using the .NET framework (System.Data.Sql.SqlDataSourceEnumerator), but is there also a relatively simple way to do this in java as […]

Which account is used when executing xp_cmdshell 'wmic … “java -jar …”'

I have a jar file that I want to run as a step in an SQL Job. However, the jar file has to run on machineA but the SQL job is schedule on serverA. To make this possible, in serverA’s SQL job, I use xp_cmdshell to issue a wmic command to the terminal. xp_cmdshell permits […]

Can not connect to ms sql server using windows authentication on remote system

I was trying to connect to ms sql server 2008 which is installed on a remote system.But it showing error.The following is the way i had tried import java.io.File; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; public class mssql { public static void main(String[] args) { try { Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”).newInstance(); Connection connection=DriverManager.getConnection(“jdbc:sqlserver://192.168.1.220:1433;databaseName=sales;integratedSecurity=true;”); if(!(connection==null)) […]

Specific Caching Scenario for Web Application

I am making a web application that involves being able to grab specific computer logs from multiple department stores. The application is getting data from a SQL Server DB. At the start of the app I ask the user to select a region number to narrow down their choices. After the region selection is made […]

Hibernate: connection.url for SQL Server .MDF File

How do I Hibernate connection.url for SQL Server .MDF File? I’ve tried prop.setProperty(“hibernate.connection.url”, “jdbc:sqlserver://c:\\db.mdf”); but don’t work 🙁 Thx!

java.sql.SQLException: Invalid state, the ResultSet object is closed

I am trying to run StoredProcedure using jtds. My database is on SQL SErver 2008 private String DRIVER_NAME_VALUE = “net.sourceforge.jtds.jdbc.Driver”; private String URL_VALUE = “jdbc:jtds:sqlserver://”; … cstmt =dbConnection.getCallableStatement(“{? = call dbo.GetAgentStats (?)}”); . . . rs = cstmt.executeQuery(); when trying to go over the Result set I got the Exception: java.sql.SQLException: Invalid state, the ResultSet […]

passing empty field as parameter in jasper ireport

The query select * from db_accessadmin.customerSummary where (accountNumber = $P{accountNo} or $P{accountNo}=”) and (ppuserMobile = $P{mobileNo} or $P{mobileNo}=”) and ( ppuserStaticID = $P{customerId} or $P{customerId} = ”) and (cast(requestDate as date) between (cast($P{fromDate} as date)) and (cast($P{toDate} as date))) The aim is to generate a report in jasper depending on the values of the parameters. […]

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