01.
package
com.java.myapp;
02.
03.
import
java.sql.SQLException;
04.
import
java.sql.Statement;
05.
import
java.sql.Connection;
06.
import
java.sql.DriverManager;
07.
08.
public
class
MyClass {
09.
10.
public
static
void
main(String[] args) {
11.
12.
Connection connect =
null
;
13.
Statement s =
null
;
14.
15.
try
{
16.
Class.forName(
"oracle.jdbc.driver.OracleDriver"
);
17.
connect = DriverManager.getConnection(
""
+
18.
"jdbc:oracle:thin:@TCDB"
,
"myuser"
,
"mypassword"
);
19.
20.
s = connect.createStatement();
21.
22.
String sql =
"INSERT INTO customer "
+
23.
"(CUSTOMERID,NAME,EMAIL,COUNTRYCODE,BUDGET,USED) "
+
24.
"VALUES ('C005','Chai Surachai','chai.surachai@thaicreate.com'"
+
25.
",'TH','1000000','0') "
;
26.
s.execute(sql);
27.
28.
System.out.println(
"Record Inserted Successfully"
);
29.
30.
}
catch
(Exception e) {
31.
32.
e.printStackTrace();
33.
}
34.
35.
try
{
36.
s.close();
37.
connect.close();
38.
}
catch
(SQLException e) {
39.
40.
e.printStackTrace();
41.
}
42.
43.
}
44.
45.
}