Raymond823
February 3rd, 2002, 10:24 PM
Hi!
I wanted to make a javabean which will allow the user to specify the fields of a table and use this field as a parameter in my prepared statements, for example in the jsp page:
String fieldval[];
fieldval = new String[5];
fieldval[0] = "My Name";
fieldval[1] = "23";
:
:
myBean.InsertToTable(fieldval)
my java bean code should be something like this:
public void InsertToTable(value[])
{
PreparedStatement insertValues;
String stmt = "insert into myTable values("
for (i=0; i< size of array-1; i++)
stmt = stmt + "'" + value[i] + "'" + ",";
stmt = stmt + "'" + value[size of array] + "')";
insertValues = myConn.prepareStatement(stmt);
}
my problem here is how to get the "size of array" since it will only be determined by the one writing the jsp page. I hope that I was able to explain this clearly. Thanks in advance!
I wanted to make a javabean which will allow the user to specify the fields of a table and use this field as a parameter in my prepared statements, for example in the jsp page:
String fieldval[];
fieldval = new String[5];
fieldval[0] = "My Name";
fieldval[1] = "23";
:
:
myBean.InsertToTable(fieldval)
my java bean code should be something like this:
public void InsertToTable(value[])
{
PreparedStatement insertValues;
String stmt = "insert into myTable values("
for (i=0; i< size of array-1; i++)
stmt = stmt + "'" + value[i] + "'" + ",";
stmt = stmt + "'" + value[size of array] + "')";
insertValues = myConn.prepareStatement(stmt);
}
my problem here is how to get the "size of array" since it will only be determined by the one writing the jsp page. I hope that I was able to explain this clearly. Thanks in advance!