Tag: java

Connect with SQL Server 2005 Express with Java

I have problem with my project. It’s making me crazy – maybe you can help me. I have a PC running SQL server 2005 Express and it works nicely. In Eclipse I tested the following code to query the database: String user= “sa”; String pass= “root”; Statement smt; ResultSet rs = null; System.out.println(“2”); try { […]

Jdbc Connection Pool with Sql Server 2008 fails

I am trying to turn my jdbc code to use Connection Pool functionality on Tomcat. My system is a jsp/servlet application that connects to an SQL Server 2008. So, lets get to the code… My Connection class looks like this: import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.PoolProperties; //… some more imports public class DbPooledConnectionToMSSQL { public String dbsource […]

The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (“”): Data type 0x38 is unknown

Trying to connect to sqlserver DB and retrieve info and later insert to it. On the server getting this error when trying to make a JDBC call with select. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (“”): Data type 0x38 is […]

SQL Server query from Java gets no results

OS: Windows Server 2012 Database: SQL Server 2012 Additional Software: jdk-7u51-windows-x64, apache-tomcat-7.0.50, Ant 1.9.3 I’m migrating a website from Linux/MySQL to Windows/SQL Server. One of the problems I have: I’d like to execute the SQL query SELECT r.PatientID, r.StudyDate, r.StudyTime, MeanCTDIvol_in_mGy, @@ROWCOUNT as ‘rowcount’ FROM report r INNER JOIN ct_irradiation_events e ON r.rdsr_id = e.rdsr_id […]

Create mssql trigger from java program

Is it possible to create a trigger from java using mssql jdbc driver? I am having one audit trigger which is saved in a .sql file. The UI will show all the tables available in client db. Sometimes they need to enable the auditing for some specific tables, so I need to run the sql […]

50894 ERROR reading: Incorrect syntax near the keyword 'user' when tries to select query to compare the username and password

public void login(String name,String password) throws SQLException{ try { Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); } catch (ClassNotFoundException ex) { Logger.getLogger(SocketServer.class.getName()).log(Level.SEVERE, null, ex); } java.sql.Connection conn = DriverManager.getConnection(“jdbc:sqlserver://;”+”user=looi963;password=1234;database=user”); PreparedStatement state=conn.prepareStatement(“Select username,password from user where username=? and password = ?”); state.setString(1,name); state.setString(2, password ); int count = state.executeUpdate(); if(count>0){ System.out.println(“Successful login”); } }

Cannot open port 1433 for Azure SQL database in Mac

I’m trying to access a Azure-hosted SQL database on my java application. I checked the port 1433 using nmap and it shows that it’s closed: Starting Nmap 7.12 ( https://nmap.org ) at 2016-09-02 09:44 PHT Nmap scan report for localhost ( Host is up (0.00014s latency). Other addresses for localhost (not scanned): ::1 PORT STATE […]

Jar file not running from MSSQL stored procedure?

Hi All I’m trying to run a jar a file from MSSQL stored procedure. But I’m getting the error “‘java‘ is not recognized as an internal or external command,” I’m using the following command from stored procedure EXEC master..xp_cmdshell ‘java -jar C:\admin\yyyyy\xxxx.jar’ I have installed JRE and also added it in environment variables. I’m able […]

How can I set bit column to null?

The following only wants a primitive boolean (true or false). psmt.setBoolean(5, boolean) ; //wants primitive What if I want to set the bit to null? Sql server = [bit] NULL

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 […]

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