A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
JDBC and Relational Databases
MySql array (workarounds?)
Joined: Aug 30, 2005
Jun 01, 2006 10:27:00
Hi Guys : I wanted to insert a hashtable of name value pairs into mysql.
I know one way of doing this is to do
insert into myTable values (1,'jay'), (2,'jim') , etc...
but Id rather have a mysql stored procedure handle the creation
of this statement (so that
I can avoid having sql in my
Any ideas for a work around ?
Ideally, Id like to insert as a
and have an SP handle the parsing...
author & internet detective
Joined: May 26, 2003
Jun 01, 2006 20:04:00
If you really want to use a stored procedure, you could pass two arrays to the stored proc: one with the names and one with the values. Not sure if mySql supports this though.
I think it would be clearer to do this in Java though. You could use a PreparedStatement:
nsert into myTable values (?, ?)
If you use
's batch update, you can still do all the updates in one server roundtrip. Also, you can get the SQL out of the Java code by a putting it in a property file.
OCA 8 book
How To Ask Questions The Smart Way
Blogging on Certs:
SCEA Part 1
Part 2 & 3
Core Spring 3
TOGAF part 1
Author and ninkuma
Joined: Jan 10, 2002
Jun 02, 2006 08:32:00
There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the
JavaRanch Naming Policy
adjust your display name
to match it.
In particular, your display name must be a first
a last name separated by a space character, and must not be obviously fictitious.
Asking smart questions
Books by Bear
I agree. Here's the link:
subject: MySql array (workarounds?)
getBlob throws OutOfMemoryError ?
Hibernate smart enough to avoid FK issues?
Design dilemma:Mysql stored procedure or java business objects?
Synchronizing MySQL with FileSystem
MqSQL to Oracle
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015