database - java.sql.SQLSyntaxErrorException: ORA-00928: missing SELECT keyword -
i error when inserting rows database.
code
public class insertrowdata { public static void main(string[] args)throws classnotfoundexception, sqlexception{ connection con = (connection) drivermanager .getconnection("jdbc:oracle:thin:@localhost:1521:orcl" , "system" , "system"); statement statement = con.createstatement(); string dmlinsert = "insert student(111,manoj,rawatrulz09)"; int rowseffected = statement.executeupdate(dmlinsert); system.out.println("no of rows effected" + rowseffected); } } after searching in google found solution remove single quotes column still getting same error. p.s-i newbie
this bad approach insert data table.
string dmlinsert="insert student(111,manoj,rawatrulz09)"
first of all, query missing syntax values.
when columns not mentioned while inserting, values must contain same amount of data , respectively.
but when inserting data best practice mention columns, if in later time make change table in database, insert query stays stable. e.g: insert student(id, name, email) values(111,'manoj','rawatrulz09').
now, if in future add column table, insert query still work has mentioned columns, if won't mention columns code start giving error when executed no of values don't match given table etc... luck! anyway, answer insert query:
insert student values(111,'manoj','rawatrulz09')
Comments
Post a Comment