Delete data of a database from Java

public class DeleteDB{ static String db="//localhost:3306/cdcol"; static String user="root"; static String passw=""; static String driver= "com.mysql.jdbc.Driver"; static String url="jdbc:mysql:" + db; public static void main(String[] args) throws ClassNotFoundException { try { Class.forName(driver); Connection con; Statement stat; con=DriverManager.getConnection(url, user, passw); stat=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); System.out.println("Start"); int x=stat.executeUpdate("DELETE FROM cds WHERE titel='11'"); stat.close(); con.close(); } catch (SQLException ex) { Logger.getLogger(InsertDb.class.getName()).log(Level.SEVERE, null, ex); } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.