Tag: java

“Repeated column in mapping for entity” where each column is only mapped once

I have a hibernate mapping file ParcelServicePresetIds.hbm.xml: <hibernate-mapping> <class name=”de.delife.sql.ParcelServicePresetIds” table=”ParcelServicePresetIDs” schema=”dbo” catalog=”xxx”> <id name=”id” type=”int”> <column name=”ID” /> <generator class=”assigned” /> </id> <many-to-one name=”itemsBase” class=”de.sql.ItemsBase” fetch=”select” property-ref=”itemId”> <column name=”ItemID” /> </many-to-one> <property name=”itemId” column=”ItemID” type=”java.lang.Integer”/> <property name=”intValue” type=”java.lang.Integer”> <column name=”intValue” /> </property> </class> </hibernate-mapping> When I run my program I get an error: Initial […]

Getting Checked Exception while running a SQL Program

import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.PrintWriter; import java.sql.*; import java.net.*; public class connection { JTextField textfeild; JButton button; String text; Socket sock; PrintWriter writer; JButton button1; public static void main(String[] args) { connection user1 = new connection(); user1.go(); }//main method close public void go() { JFrame frame12 = new JFrame(); JPanel centerpanel12 = […]

Running composite query on SQL server 2014 does not return result set

We have the following code: Connection conn = null; String dbURL = “jdbc:sqlserver://DBDerver details here”; String user = “user name”; String pass = “password@123”; try { Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); conn = DriverManager.getConnection(dbURL, user, pass); String sql = “update Table1” + “set DBID = DBID+1 where TABLENAME = ‘” + “Table2” + “‘;” + “select DBID from Table […]

Java: INSERT INTO inside a loop using Result Test

I am having a small problem while I try to insert some data in my database (MS – SQL). I am using this code (I just copy-paste all of it, so someone might understand smth that I don’t) try { Connection connection = null; Statement Statement = null; ResultSet ResultSet = null; String query = […]

Escape value in MSSQL Server with Java

How can I escape a value for usage in a query to MSSQL Server? I know how it would be possible using JDBC but since I’m using SAP Business One DI API there is no way (I’m aware of) of using prepared statements. It would be sufficient to know how to escape string values while […]

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

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