Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Other Development Tools
 Java and Stored Proc with User Defined Table Type
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 08/09/2012 :  21:32:09  Show Profile  Reply with Quote
Hello All,

In searching the web for this, it seems very few people have tried or think it may be impossible. I'm really hoping someone here may have an answer to it:

I'm newer to Java, but very experience in C# and have found most of what I need. I've figured out how to call a stored procedure(MS SQL 2008) with Java, but I cannot seem to find how I would pass a User Defined Table Type as an input:

The table type:

CREATE TYPE [dbo].[MyTableType] AS TABLE(
	[id] [int] NOT NULL,
	[year] [int] NOT NULL,
	[day] [int] NOT NULL,
	[month] [int] NOT NULL

The stored procedure:

	@myData MyTableType READONLY
	insert into PermanentDataTable ([id], [year], [day], [month])
		select	*
		from	@myData

Very simple and tested.... Now how do I call this from Java:

String sql = "exec dbo.InsertSomeData @myData=?";
PreparedStatement ps = connection.prepareStatement(sql);
ps.setThatThingIWantToDo(1, arrayOfData); // <-- This part is where I'm stuck

Thanks in advance for any help

Edited by - sidestepper on 08/09/2012 21:34:16
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000