Search
 
SCRIPT & CODE EXAMPLE
 

SQL

java sql insert return id

Resultset result;
PreparedStatement prep;
String query = "INSERT INTO myRel (data) VALUES (?)";

prep = db.prepareStatement(query ,Statement.RETURN_GENERATED_KEYS);

result = prep.getGeneratedKeys();

if(result.next() && result != null){
   System.out.println("Key: " + result.getInt(1));
} else {
   System.out.println("No, Nop nada");
}
Comment

PREVIOUS NEXT
Code Example
Sql :: sql join on comma separated field 
Sql :: multiple left join mysql 
Sql :: mysql max() 
Sql :: insert to postgres table 
Sql :: Split JSON data in SQL Server column 
Sql :: SQL Query to delete all the tables in a database 
Sql :: how to update sql server version 
Sql :: microsoft sql server python connection 
Sql :: SQL Primary Key multiple column 
Sql :: lost connection to mysql server during query when dumping table 
Sql :: select only distinct values from another table 
Sql :: pgadmin postgres ERROR: database is being accessed by other users 
Sql :: delete table sqlite 
Sql :: sqlite clear shell 
Sql :: operator in sql 
Sql :: sql nombre mes mysql 
Sql :: how to check which table has data in mysql 
Sql :: select where mysql 
Sql :: calculer pourcentage mysql 
Sql :: sqlite löschen einer tabelle 
Sql :: extract postgresql 
Sql :: excel vba import data to sql server 
Sql :: oracle datafile max size 32gb 
Sql :: how to dump .csv file into mysql 
Sql :: oracle logfile switch 
Sql :: how to find columns with null values in sql 
Sql :: SQL Comments Within Statements 
Sql :: grab part of a string sql 
Sql :: timestamp(0) postgresql 
Sql :: oracle sql count occurrences of value in column 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =