I wan't to make a page that "if i enter a value in the textbox and i press submit button in the jsp page will link the data to the jsp page by getting the data in the data base using the odbc in ms access?
someone can help me

Dani AI

Generated

wanted to submit a textbox value from a JSP page and save/read it from MS Access. As hinted, the missing pieces are (1) a form that POSTS the data, (2) server-side code that reads request parameters, and (3) a JDBC driver that talks to Access. Do not put JDBC code directly in a JSP—use a servlet or a DAO class so the view (JSP) stays separate from data code.

A practical, modern route is UCanAccess (pure Java JDBC driver for .mdb/.accdb). Put the ucanaccess and its dependency jars in WEB-INF/lib, then have a servlet that reads parameters and uses a PreparedStatement to insert or query. Example (trimmed) servlet code for insertion:

Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
String url = "jdbc:ucanaccess://C:/path/to/db.accdb";
Connection conn = DriverManager.getConnection(url);
PreparedStatement ps = conn.prepareStatement("INSERT INTO people(name,age) VALUES(?,?)");
ps.setString(1, request.getParameter("name"));
ps.setInt(2, Integer.parseInt(request.getParameter("age")));
ps.executeUpdate();
ps.close();
conn.close();

Notes: always use PreparedStatement to avoid SQL injection. Access is fine for small/internal apps but not recommended for multiuser web apps—consider MySQL/Postgres for production. For setup and jars see the UCanAccess project and review JDBC basics at JDBC basics (Oracle Java tutorial).

Recommended Answers

All 2 Replies

If you checked out very first post of JSP section, there wouldn't be any need for this post...

commented: Tsk... Tsk... Tsk ... What is daniweb coming down to ..... Shameless self promotion even from a Moderator :P +4

ahhmm... tanks for that...^^

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.