Tag: java

JPA query for table with name user with Hibernate

I try to build a findAll query for a class with name User. With Hibernate’s SessionFactory it is working fine, but with Hibernate’s EntityManager I get an error. The reason seems to be the escaping (with brackets [and ]) of the MS SQL Server keyword user, but with EntityManager#persist(Object) and EntityManager#find(Class, Object) I have no […]

Using Java to Export Binary Data from SQL Server

I have a database table with 7500 records in it. I am trying to write something that can export all 7500 jpg images to a folder on my laptop and name them based on EMPID + TYPE. So the blob would be named 1008421_0.jpg for the first row I was thinking something like this but […]

How save old ID from MSSQL when insert entity to new DB ORACLE?

I write DB migrate utilite. I have MSSQL DB. Some tables. There are many rows in each table. I have empty Oracle DB. I have entities for tables. I create 2 conections. to MSSQL and to ORACLE. I create 2 DAO In 1 DAO I get all data from MSSQL List<Payment> payments = PaymentService.me().getPayments(); After […]

Could not load JDBC driver class when deploying application to remote tomcat server

I have put the sqljbc4.jar file into the apache-tomcat-7.0.69/lib file on the server I am trying to host the application on. The application runs when I run it from within intellij where the local tomcat has the same .jar in the /lib folder. The problem only seems to arise when I try and deploy the […]

Java Wildfly-Swarm: How to use JDBC with SQL Server (T-SQL)

I’m using Wildfly-Swarm to build up a java web application on microsoft azure. My Configuration: JDK 8.0 Wildfly-Swarm 1.0.0.Beta8 Maven 3.2 JDBC 4.2 Microsoft SQL Server pom.xml <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd”> <modelVersion>4.0.0</modelVersion> <groupId>com.example.azure.swarm</groupId> <artifactId>AzureSwarmTest</artifactId> <name>Wildfly Swarm Example</name> <version>1.0.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> <version.sqlserver>4.0</version.sqlserver> <version.wildfly.swarm>1.0.0.Beta8</version.wildfly.swarm> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <failOnMissingWebXml>false</failOnMissingWebXml> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.wildfly.swarm</groupId> […]

ResultSet is empty, event though the sql query is ok

I have the following Stored Procedure: ALTER PROCEDURE Uspinformation3 (@TypeNr VARCHAR(50), @Process VARCHAR(50), @StartDate VARCHAR(50), @EndDate VARCHAR(50)) AS BEGIN try SET dateformat dmy; SELECT Count(rownr) FROM diff_ct WHERE type_number = @TypeNr AND process = @Process AND full_time_stamp BETWEEN @StartDate AND @EndDate END try If I execute the Procedure from SQL Server, it gives me the […]

Unable to fetch data from SQL Server using JDBC on Raspbian (Works on Windows but not on Raspbian Jessie)

I wrote some code which is supposed to pull information from my SQL server to tell what item is currently running. The code runs fine on my windows machine, however I plan on running this on a raspberry pi running Raspbian Jessie. When I run the code it gives me the error com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP […]

Escaping special characters using hibernate criterias

I’m facing a non usual issue while using criterias. I want to do a criteria with a like clause but the text contains special chars like the bracket char “[” and it seems that it’s a special char in MSSQL database. From an sql query I must use the special wording ESCAPE see example : […]

How to implement “is–a” relationship when parent and child have separate Ids

I have 2 tables: person and user. Each user is a person. Each person is not a user. Each table has its own PK. This is the DDL of the tables: CREATE TABLE person ( person_pk int NOT NULL PRIMARY KEY, first_name varchar(50) NOT NULL, middle_name varchar(50) NULL, last_name varchar(50) NOT NULL ); CREATE TABLE […]

SQL Error code SQL state ; error code ;

I am getting the below logs on one of my JSP-Servlet application. Can anyone explain me what **SQL state [S1093]; error code [0];** means? Or what could be the issue? I have already checked the column name JOB_SYNDICATELOCALE, it is correct. getSchedulerDetail operation started. 12:50:35,181 INFO [stdout] (ajp-/0.0.0.0:9209-6) Error in getSchedulerDetail() StatementCallback; uncategorized SQLException for […]

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