Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
Java
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Data");

Statement stmt=con.createStatement();
try
{
stmt.executeUpdate("insert into smstable values('"+message+"','"+no+"')");
out.println(" sucessfull");
}catch(Exception e)
{
	out.println("not inserted");


}
Posted
Updated 31-May-11 9:12am
v4
Comments
Manfred Rudolf Bihy 30-May-11 12:46pm    
Added <pre> tags!
Sandeep Mewara 30-May-11 14:10pm    
So, did you try to fix whatever is wrong? Do you know what (all) is wrong?
TorstenH. 31-May-11 3:55am    
..and what's the exception saying?

1 solution

You do not provide much information, so it's just guessing what the problem could be. I noticed that the second parameter is called 'no'. If 'no' is numeric your statement should look like this:

stmt.executeUpdate("insert into smstable values('"+message+"',"+no+")");


Another possibility is that one or more values exceed the fieldsize limit.


If that is not the problem then add the following line in the catch block:

out.println(e.Message);

or look at the innerexception (if available) for more information and update your question with the extra information.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900