Hi,
In the question itself there is an answer. You are reading from a file and storing it in a String and Prepared Statement takes String.
Simple Example: Lest's assume EmapleArray is a File and every element is a Line or Character. I am appending every line to the String psmtString in the for loop. Once the loop is done it will be a complete String that want to insert into DB using preparedStatement.setString(1,pstmtString).
String[] ExampleArray = {
"Sun Solaris"
, "HP-UX"
, "Linux"
, "MS Windows"
, "Macintosh"
};
String psmtString="";
for(int i=0; i< ExampleArray.length; i++)
{
psmtString+=ExampleArray;
}
System.out.println(psmtString);
If you think the File is very big the use StringBuffer insted of String.
String[] ExampleArray = {
"Sun Solaris"
, "HP-UX"
, "Linux"
, "MS Windows"
, "Macintosh"
};
StringBuffer psmtString= new StringBuffer();
for(int i=0; i< ExampleArray.length; i++)
{
psmtString.append(ExampleArray);
}
System.out.println(psmtString.toString());
pstmt.setString(1,psmtString.toString());
Hope this will help you..
Cheers
Venu