hi all how are u? i have a problem and i need your help ..i have a code in java that connect to a mysql DB and update the rows of the table ...but i have a problem ...the new updated column called (original_text) contains the updated columnss from the column (content) but the while loop is not right coz the loop keep inserting the text in the new column without stopping ..i don't know what to do..and sorry for my bad english ...thnx alot in advance ...
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Conversion;
import java.sql.*;
//import javax.management.Query;
/**
*
* @author weblover
*/
public class DataBaseConvertor {
public static void main (String [] args) throws Exception
{
//Vector<text> Alltext = new Vector<text>();
Convertor c = new Convertor();
String after = "";
String before = "";
String id = "";
int number=0;
int oldnumber=0;
int chapter_number =0;
int length=0;
Connection conn = null;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/quran", "root", "");
Statement stm = conn.createStatement();
Statement stm1 = conn.createStatement();
String Query = "SELECT * FROM `qtable_ar`";
ResultSet res = stm.executeQuery(Query);
while (res.next()){
before = res.getString("content");
id = res.getString ("id");
oldnumber = Integer.parseInt(res.getString("number"));
chapter_number = Integer.parseInt(res.getString("chapter_number"));
c.SetBefore(before);
after = c.Converte();
length = c.getLength();
number = c.newNumber(chapter_number, oldnumber);
//AllAyat.add(new Aya(id, chapter_number, number, before, after, length));
Query = "UPDATE `qtable`.`qtable_ar` SET `original_text` = '"+after+"', `length` = '"+length+"', `number` = '"+number+"' WHERE `qtable_ar`.`id` ="+id+" LIMIT 1 ;";
//System.out.println(after);
stm1.executeUpdate(Query);
}
}
catch (Exception ex)
{
System.err.println("Exception : " + ex.getMessage());
}
finally {
try {
if (conn!=null) {
conn.close();
}
} catch (SQLException e) {
System.err.println("SQL Exception : "+ e.getMessage());
}
}
}
}