I want to insert list of string into Database so usual we will store string directly to database by either using prepared statement or batch statement like that but now I want to insert list of string into database so I have used prepared statement
List<String> Account_Number = Files.lines(Paths.get("D:\\PDFTOEXCEL\\Extractionfrompdf.txt"))
.filter(s -> s.contains(arra.get(7)))
.map(s -> s.split(":")[1].trim())
.collect(Collectors.toList());
System.out.println(Account_Number);
try {
Connection conn = PDFTOEXCEL.getConnection();
PreparedStatement stmt = conn.prepareStatement("insert into client_info values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
stmt.setString(1, Account_Number.get(1));
int k = stmt.executeUpdate();
I have about 31 columns in my database just for showing I have posted only one in this code all are in the list of string only
So now I am getting error in :
while (query_set.next()) {
row_counter = row_counter + 1;
**Account_Number = query_set.getString("Account_Number");**
Output:
Error:incompatible types: String cannot be converted to List
The bold one is the error statement