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();
}
}
}
bhallarahul
-4
Light Poster
Recommended Answers
Jump to Postwhich database Engine you want to connect
Jump to PostPlease 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?
Jump to PostMaybe 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`
All 10 Replies
mKorbel
274
Veteran Poster
dononelson
2
Junior Poster in Training
ivatanako
1
Junior Poster
bhallarahul
-4
Light Poster
bhallarahul
-4
Light Poster
bhallarahul
-4
Light Poster
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
ivatanako
1
Junior Poster
bhallarahul
-4
Light Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.