Tag: java

Using a database API cursor with JDBC and SQLServer to select batch results

SOLVED (See answer below.) I did not understand my problem within the proper context. The real issue was that my query was returning multiple ResultSet objects, and I had never come across that before. I have posted code below that solves the problem. PROBLEM I have an SQL Server database table with many thousand rows. […]

Unable to execute stored Procedure using Java and JDBC on SQL server

I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I use when setting up the stored procedure call in code I get an error stating that the stored procedure couldn’t […]

How can I version control Stored Procedures while using flywaydb?

I currently have a Java web app which uses a Microsoft SQL Server back end. Database migrations are currently being done manually by sqlcmd which makes use of the :r command to reference script files of our stored procedures and views. This way each stored procedure has his own file “proc_someprocedure.sql” The migration is done […]

How do I use Java to read a .csv file and insert its data into SQL Server?

I am very new to Java. I have a task with two steps. I want to read all data from a .csv file. After reading that data I have to put it into a SQL Server database. I have done step one. I’m able to read the .csv file data, but I don’t know that […]

Passing a user-defined table type to a SQL Server stored procedure using JDBC

We’ve got this User-Defined-Table Type in MS SQL Server: CREATE TYPE [dbo].[INITVALS_MSG] AS TABLE( [SDate] [decimal](8, 0) NOT NULL, [EDate] [decimal](8, 0) NOT NULL, [PlantCode] [nvarchar](10) NOT NULL, [LoadType] [nchar](8) NOT NULL, [Asset] [bigint] NOT NULL ) and a Stored Procedure which takes that table as input: ALTER PROCEDURE [dbo].[RegisterInitAssets] @initmsg INITVALS_MSG ReadOnly AS BEGIN […]

getting value from jDateChooser and saving to MS sql DB

I have two jDateChooser on my dialog , I want to save to MS-SQL DB having issue with that data types. Any idea how to fix this issue ! I can only do this when i convert data type to nvarchar in DB and convert the value to string which returns from jDateChooser. // I […]

MSSQL driver is not loaded by Tomcat

I am trying to deploy my webapp to a Tomcat container, but I get an exception stating that no driver for my database can be found. Locally I test the app on Jetty and the driver-jar is provided by Maven. I copied the driver-jar to the lib folder in the Tomcat home folder, but I […]

Connection JDBC SQL Server Error

I’ve tryed to create a connection with a Microsoft SQl Server 2008 database through JDBC on Eclipse SDK. I’ve dowloaded JDBC driver from microsoft and I’ve installed it, then I’ve added at my System environment variables CLASSPATH the path of sqljdbc4.jar file. After icluding in the Eclipse project the jar file I’ve tryed to create […]

Can a Java application running on a Window's Server connect to SQL Server via Windows Authentication

Let me give some background before I ask my question. I’m at a shop that primarily runs Windows. We have several batch applications running on Windows Servers (mostly 2003). Most of these batch applications are written in C# and C++; however we have a handful of applications that are written in Java. The batch Java […]

how to execute bulk insert statement in java (using JDBC) with db=SQL Server 2008 Express

I am trying to execute a BULK INSERT statement on SQL Server 2008 Express. (It basically takes all fields in a specified file and inserts these fields into appropriate columns in a table.) Given below is an example of the bulk insert statement– BULK INSERT SalesHistory FROM ‘c:\SalesHistoryText.txt’ WITH (FIELDTERMINATOR = ‘,’) Given below is […]

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