import java.sql.Statement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.DriverManager;
import java.sql.ResultSet;
class db
	{
		public static void main(String arg[])
			{
				Statement statementObj=null;
				Connection connectionObj=null;
				try
					{
						Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        			connectionObj=DriverManager.getConnection("jdbc:odbc:sensorData","","");
			                        statementObj=connectionObj.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
						System.out.println("do not worry ho ga yr ho ga");
						statementObj.executeUpdate("INSERT INTO hardwareData (Time, Date, humidity, Temp, DiesalLevel) VALUES('1','12','3','s','a')");
						connectionObj.close();
					}
				catch(ClassNotFoundException e)
					{
						System.out.println("class not found exception");
					}
				
				catch(SQLException e)
					{
						e.printStackTrace();
					}
			}   
       }

Edited 5 Years Ago by Ezzaral: Fixed code tags

Please put your code snippets within

blocks in the future - it makes it easier for us all to read.

Can you post your exception stack so we can see what might be going wrong?

Maybe in the database your using. The TIME and DATE are reserved keywords that you should escape first. for sql, [TIME],[DATE]. For mysql, `TIME`,`DATE`

it shows
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in
INSERT INTO statement.
And it all the field of data base is Text.

Maybe in the database your using. The TIME and DATE are reserved keywords that you should escape first. for sql, [TIME],[DATE]. For mysql, `TIME`,`DATE`

if i use this Statement:
statementObj.executeUpdate("INSERT INTO hardwareData VALUES('1','12','3','s','a')");
where in database fields are
Time:Text
Date:Text
humidity:Text
Temp:Text
DiesalLevel:Text

INSERT INTO hardwareData ([Time], [Date], humidity, Temp, DiesalLevel) VALUES('1','12','3','s','a')
INSERT INTO hardwareData ([Time], [Date], humidity, Temp, DiesalLevel) VALUES('1','12','3','s','a')

First of all THANK YOU. My code is working.
Can you tell me please why we required square bracket in Time and Date field

This question has already been answered. Start a new discussion instead.