Tag: java

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

Bad SQL Grammar near ')' while using Spring and WHERE IN clause

I keep getting this exception org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT id, name FROM pts WHERE id IN ()]; nested exception is java.sql.SQLException: Incorrect syntax near ‘)’. Here is the function where my SQL is being executed public List<ParentPt> getParentPtsFromWorkPackage(String workPackage) { Set<Integer> ptNums = getParentPtNums(workPackage); MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(“ptNums”, ptNums); String sql […]

SQL Server “Application=Intent” not working JDBC

Im am trying to hit the secondary node on a sql server 2012 DB using “applicationIntent=ReadOnly” in connection string. It is still hitting the primary node, not sure why. Im using sqljdbc4-4.0 jar java JDBC call: ResultSet results = null; PreparedStatement preparedStatement = null; Connection conn = null; String SQL_SERVER_DRIVER = “com.microsoft.sqlserver.jdbc.SQLServerDriver”; Class.forName(SQL_SERVER_DRIVER); String dbString […]

MS SQL dead lock for multi thread

I have a very simple table SEQ_NO in MS SQL server 2014, the table structure is as following: CREATE TABLE SEQ_NO( KEY_CODE varchar(30) NOT NULL, CURR_SEQ_NO numeric(38, 0) NOT NULL, PRIMARY KEY (KEY_CODE) ) This table has only 4 records, each of them contains a sequence number. I have a program which has many threads […]

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