aspose file tools*
The moose likes JDBC and the fly likes insert data to MS Access using JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "insert data to MS Access using JAVA" Watch "insert data to MS Access using JAVA" New topic

insert data to MS Access using JAVA

Jeremy Ray Dean

Joined: Oct 21, 2003
Posts: 1
I'm doing a project for an Info. Sys. Class, and we need to be able to insert values into tables in MS Access using Java. We've already got the JDBC-ODBC bridge and are able to view Tables and Queries through our applet, but I can't quite figure out how to insert new data into the tables. Anyone out there know of some good Java-to-MS SQL links???
Amit More

Joined: Oct 16, 2003
Posts: 24
Here is the code which will insert the values in to access database table 'Emp' :
Connection con;
PreparedStatement ps = null;
Statement stmt = null;
String name;
int sal;
name = request.getParameter("txtName");
sal = Integer.parseInt(request.getParameter("txtSal");
con=DriverManager.getConnection("jdbc dbc:Amit");

String sql = "INSERT INTO Emp(Name, Salary) VALUES (?,?)";
ps = con.prepareStatement(sql);
stmt = con.createStatement();

ps.setString(1, name);
ps.setInt(2, sal);

Thanks,<br />Amit
I agree. Here's the link:
subject: insert data to MS Access using JAVA