import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.sql.Connection; public class javaupdate { public static void main(String[] args) throws ClassNotFoundException,SQLException{ Connection conn = null; Statement st = null; String username = "system"; String password = "1808"; String QUERY = "UPDATE employee set job = 'manager' where empno=7999"; try{ conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/XE", username, password); st = conn.createStatement(); int rows = st.executeUpdate(QUERY); System.out.println(rows); }catch(SQLException e) { e.printStackTrace(); } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter