Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class jdbc1{
- public static void main(String[] args) throws SQLException {
- Connection conn= null;
- String url= "jdbc:postgresql://172.16.1.99:5432/chinook";
- conn = DriverManager.getConnection(url, "ut99999", "pw99999");
- Statement st=conn.createStatement();
- // int numero_riga_inserita=st.executeUpdate("insert into artist values(4001, 'forlin')");
- // inserire un nuovo artista con id massimo +1 di quelli esistenti
- ResultSet rs=st.executeQuery("select max(artist_id) from artist");
- rs.next();
- int max=rs.getInt(1);
- max++;
- int max_id=st.executeUpdate("insert into artist values(" + max + ",'arta')");
- }
- }
Add Comment
Please, Sign In to add comment