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
Author

insert data to MS Access using JAVA

Jeremy Ray Dean
Greenhorn

Joined: Oct 21, 2003
Posts: 1
Hi,
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???
Thanks,
-Jeremy
Amit More
Greenhorn

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");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
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);
ps.executeUpdate();
-----------------------------------
Amit


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