Tag: java

Pass Arraylst<Arraylist<String>> to MSSQL Stored procedure using JAVA?

Here I am trying to pass List to stored procedure but getting the following error: Operand type clash: nvarchar is incompatible with UserType //Stored Procedure ALTER PROCEDURE [dbo].[UserDetails] ( @OutId NVARCHAR(50) OUTPUT, @Type NVARCHAR(50) Type, ,@Preload UserType READONLY ) AS UserDefined datatype CREATE TYPE [dbo].[UserType] AS TABLE( [Id] [int] NULL, [Name] [nvarchar](50) NULL, [Company] [nvarchar](100) […]

Tables in SQL Server database are not auto-created

I’m trying to auto-create tables from Java in database on Microsoft SQL Server 2012. I’m using JPA and there is my persistence.xml : <?xml version=”1.0″ encoding=”UTF-8″?> <persistence version=”2.0″ xmlns=”http://java.sun.com/xml/ns/persistence” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd”> <persistence-unit name=”PU” transaction-type=”JTA”> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>DS</jta-data-source> <class>msg.Message</class> <class>msg.Response</class> <properties> <property name=”hibernate.connection.driver_class” value=”com.microsoft.jdbc.sqlserver.SQLServerDriver”/> <property name=”hibernate.dialect” value=”org.hibernate.dialect.SQLServerDialect”/> <property name=”hibernate.show_sql” value=”true”/> <property name=”hibernate.hbm2ddl.auto” value=”create”/> </properties> </persistence-unit> JDBC […]

Can't find ON Restriction to do a full LEFT JOIN in Hibernate

I am trying to make a hibernate query from a SQL query and I am struggling to do a full LEFT/RIGHT JOIN on hibernate that displays all the rows from one of the table. Important to know: DAILY_INVENTORY inventory_id (one to many) added wasted date INVENTORY id This is what I have so far.. Criteria […]

jdbc connection, login failed for user in war file

I use the following code: Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); // Make connection Connection connection = DriverManager.getConnection(“jdbc:sqlserver://sqltest.ABC.com:1433;databaseName=test5;integratedSecurity=true”); If I run my project in Eclipse under Tomcat server goes well. But if I export my project as a WAR file en start the tomcat appache I get the error message ” Login failed for user ‘DomainName / ServerName’. I do […]

What is a NullPointerException, and how do I fix it?

What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?

Facing issue on SQL Server with Elastic Search

I have integrated SQL Server with Elastic Search. I face the problem with data type TEXT and NVARCHAR(MAX). If I use any of this datatype in SQL Server, no result is returned by Elastic Search. Why does this happen? Is there any solution for this?

Display a pivot table on jsp

I’m writing a webapp where there is some pivoted data that has to be displayed in a jsp table. The query works fine in SQL Server. But I’m unable to understand how do I project the same on a jsp. There are basically 2 datepickers in my jsp. When I select any one or both, […]

EclipseLink ADD CONSTRAINT Exception

I would like to use create-or-extend-tables but eclipselink gives below error after tables were created. I am using Eclipselink 2.5.2 and db is MS Sql 2014 Exception [EclipseLink-4002] (Eclipse Persistence Services – 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: ‘announcementCOMPANY_ID’ object already exists. Error Code: 2714 Call: ALTER TABLE announcement ADD CONSTRAINT announcementCOMPANY_ID FOREIGN KEY (COMPANY_ID) REFERENCES […]

JTDS driver – Cannot create PoolableConnectionFactory (I/O Error: DB server closed connection.)

I am attempting to connect to an SQL database hosted in Azure from a piece of software I’m using on an Azure VM, using the JTDS JDBC Driver. This isn’t software I have built/am developing, this is a third party program I am using to view my data. In the software I create data sources […]

Can't use DataSource after lookup

I am creating a JUnit to test a part of the application that uses Apache Shiro for authentication, for this I am creating a SQLServerConnectionPoolDataSource and binding it. The problem happens when I try to lookup the DataSource and get a connection, it fails the authentication of the user configured in the SQLServerConnectionPoolDataSource. After analyzing […]

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