Sunday, 15 April 2012

java - Insert if not exists into table -


I do not want to insert INSERT in the table

so I have 2 JTextField < / Code> s and I want to add variables that I add to the JTextfield s int table but in condition that they are not present in the table

this code is And it gives me errors about queries:

  try {connection conn = DriverManager.getConnection ("jdbc: mysql: // localhost: 3306 /" + db, "root", "123456"); Stmt = conn.createStatement (); + "Where is not present (select * from router)" + + "Choose from edge edge =" + + jTextField1.getText () + "'' router. And edge 0 = '' + jTextField2.getText () + "')"); } Hold (SQLException pre) {Logger.getLogger (bdd.class.getName ()). Log (Level.SEVERE, null, ex); }   

Error:

SEVERE: null
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: there is an error in your SQL syntax; Check the manual related to your MySQL server version for the correct syntax to use from the 'where not available (select * from the router) where the edge is the edge, and' edge '= 2' / div>

Your query contains an error

  try {connection conn = DriverManager.getConnection ("Jdbc: mysql: // Localhost: 3306 / "+ db," root "," 123456 "); Stmt = conn.createStatement (); Stmt.executeUpdate ("enter router (edge01, edge02) \ n" + "edge edge, choose edge 0 & lt; in some unique fields & gt; (router from" & lt; some unique Field & gt; Select where edge edge = '' + jTextField1.getText () + "'and edge02 =' + jTextField2.getText) +" ') "}} Grip (before preclosure) {logger.get logger (bdd .class.getName ()). Logs (level .SESEE, ANNEL, X);}    

No comments:

Post a Comment