• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc related

 
karthik mama
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
the problem is i am getting a run time exception when i run this class file InsertRecord.....THE SOURCE CODE IS BENEATH


C:\mypgm>java InsertRecord
connected
Exception in thread "main" java.sql.SQLException: ORA-00984: column not allowed
here


at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:145)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1111
)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
nt.java:1279)
at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatem
ent.java:1856)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java
:1821)
at InsertRecord.main(InsertRecord.java:12)


____________________________________________________________________________

import java.sql.*;
public class InsertRecord
{
public static void main(String args[]) throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbcracle:thin:@localhost";
Connection con=DriverManager.getConnection(url,"system","mama");
System.out.println("connected");
Statement st=con.createStatement();
String sql="insert into employee values (1002,ravi,6000)";
int row=st.executeUpdate(sql);
System.out.println(row+"row created");
st.close();
con.close();

}
}
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ravi is a string, it needs to be quoted with single quotes 'ravi'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic