[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Save data into access

Posted on 2006-10-24
4
Medium Priority
?
180 Views
Last Modified: 2010-04-01
Hi: Can any one please tell me how to i write a JSP code to save the following fields into Access database. Assume that ODBC connection name is Employee.

Thanks.


Name=request.form("Name")
Address=request.form("Address")

0
Comment
Question by:mustish1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 15

Expert Comment

by:Javatm
ID: 17799944
It is not good practice to put your jdbc transactions inside a jsp, it would be better if you follow the mvc pattern. However
you can easily do it like this for just a learning experience. This is assuming that your Database has a name of Database
and that you have your Name and Address field on the page.
 
   <% Connection con; %>
    <% Statement stmt; %>
    <% ResultSet rs; %>
    <% String query; %>
    <% String url; %>
    <% String id; %>
    <%
          name = request.getParameter("Name");
      address = request.getParameter("Address");
       
            if(name != null) {
               
                  try {          

                  <!--Assuming you had setup ODBC-->  
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    url = "jdbc:odbc:Database";
                    con = DriverManager.getConnection(url);
                    stmt = con.createStatement();  

                        <!-- If not use this direct connection
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Database.mdb");
                        stmt = con.createStatement();
                        -->
             
                  query = "INSERT INTO YourTable (Name, Address) VALUES ('"+name+"', '"+address+"')";
                }
                catch (ClassNotFoundException x) {
                    x.printStackTrace();
                }
                catch(SQLException y){
                    y.printStackTrace();
                }
           }
    %>
0
 
LVL 15

Accepted Solution

by:
Javatm earned 2000 total points
ID: 17799958
Just change the database name of Database to Employee. If your interested in MVC read this:
http://struts.apache.org/
http://en.wikipedia.org/wiki/Model-view-controller
0
 

Author Comment

by:mustish1
ID: 17799996
Ok thanks. Can you also please tell me the name of any free webserver for microsoft windows which i can install on my PC.

Thanks.

0
 
LVL 15

Expert Comment

by:Javatm
ID: 17807823
Apache and Apache Tomcat.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question