vendredi 16 octobre 2015

Want to insert/update data into SQLite without modification

I have stored my data in sqlite database to further query and process.

VID, Name, Pub_List

V1,"J Martin","1,2,3,4"
V2,"J. Barria","1,2,5,6"
V3,"T. Adali","6"
V4,"A. Cichocki","5"
V5,"B. Bakal","1,6"
V6,"D. Emge","3,4"
V7,"M.Golz","3,4"

I query on V1 and V2's common PubList and if found then update the V1. But when I have updated this database one time then it cannot find the common elements. Like When I first time make query on V1 and V2, it returns common = 1,2. But in the next iteration when V1's Pub_list has been updated to 1,2 and I again check V1 and V2 Pub_list it gives only 1 not 1,2. Please guide me how can I update the data so that it would be correctly available in the next iteration also. These all columns are text type.

This is my update method

private void updatePublicationList(String s, String stringSpli, DirectedGraph dirGraph) {
try {
Class.forName("org.sqlite.JDBC");
Connection con = DriverManager.getConnection("jdbc:sqlite:C:/Users /a2z/Google Drive/DR Sohail/DATA SET AND/GDBM/PapExampleDB.sqlite");
String updateTableSQL = "UPDATE or IGNORE Verticesex set Publications = ? where VId=? "; PreparedStatement preparedStatement = con.prepareStatement(updateTableSQL); stringSpli = stringSpli.replaceAll("[\[\]]",""); preparedStatement.setString(1, stringSpli); preparedStatement.setString(2, s); preparedStatement.executeUpdate(); System.out.println("Record is updated in table Vertices ! and Vertex "+" "+ s +"now has Publications"+ stringSpli); } catch (Exception e) { System.err.println( e.getClass().getName() + ": " + e.getMessage() ); System.exit(0); e.printStackTrace(); }

    }

Thanks

Aucun commentaire:

Enregistrer un commentaire