Home Answers Viewqa SQL I cant get values in MS acces in tables

 
 


shivanand42
I cant get values in MS acces in tables
1 Answer(s)      6 months and 22 days ago
Posted in : SQL

I got problem in sending values from servlet . * i am using ms acces * i cant display my values but der is increase in number of rows

my jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- used jquery for datepicker -->

 <meta charset="utf-8" />    <title>register</title>    <link rel="stylesheet" href="css/jquery-ui[1].css" />    <script src="script/jquery-1.8.2.js"></script>    <script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>    <link rel="stylesheet" href="/resources/demos/style.css" />    <script>    $(function() {        $( "#datepicker" ).datepicker();    });    </script>

</head>
<body background="images/register.bmp">
<div id="container" style="height:500px;width:500px">

<div id="login" style="background-color:#FAEBD7;height:500px;width:350px;float:left;">
<center><h2><i><b>Registration</b></i></h2></center>
<table>
<tr>
<td><b><i>Username</i></b></td>
<td><input type="text" size="15" maxlength="30" name="username" /></td>
</tr>
<tr>
<td ><b><i>Last Name</i></b></td>
<td><input type="text" size="15" maxlength="30" name="lastname" ></td>
</tr>
<tr>
<td ><b><i>Email</i></b></td>
<td><input type="text" size="15" maxlength="30" name="email" ></td>
</tr>
<tr>
<td ><b><i>Re-enter Email</i></b></td>
<td><input type="text" size="15" maxlength="30" name="reemail" ></td>
</tr>
<tr>
<td ><b><i>New Password</i></b></td>
<td><input type="password" size="15" maxlength="30" name="newpass" ></td>
</tr>
<tr>
<td ><b><i>Gender</i></b></td>

<td><select name="gender">
  <option value="male">male</option>
  <option value="female">female</option>

</select></td>

</tr>


<tr>
<td ><b><i>DOB</i></b></td>
<td>
<input type="text" id="datepicker" name="datepicker" />
</td>
</tr>


<tr>
 <form action="./Registartion" method="post">


            <input type="submit" value="SINGUP"></input>
        </form>

        <!--  <td><INPUT TYPE="button" VALUE="SIGNUP" onClick="parent.location='page1.html'"></td>-->

</tr>
</table>
</div>
</div>
</body>
</html>

registration servlet:

package validate;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
/**
 * Servlet implementation class Registartion
 */
public class Registartion extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */


    public static String username="";
    public static String lastname="";
    public static String email="";
    public static String reemail="";
    public static String newpass="";
    public static String gender="";
    public static String datepicker="";
    public static void main(String[] args) {
        Connection con = null;
        try {



          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\myca\\demo\\authors.accdb");
    // Creating a database table
          Statement sta = con.createStatement(); 
          int i=sta.executeUpdate("insert into registration (username,lastname,email,reemail,password,gender,dob) values('"+username+"','"+lastname+"','"+email+"','"+reemail+"','"+newpass+"','"+gender+"','"+datepicker+"')");
          System.out.println("Data is successfully inserted!");
          sta.close();        

          con.close();        
        } catch (Exception e) {
          System.err.println("Exception: "+e.getMessage());
        }
    // TODO Auto-generated constructor stub
    }


    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
         username=request.getParameter("username");
         lastname=request.getParameter("lastname");
         email=request.getParameter("email");
         reemail=request.getParameter("reemail");
         newpass=request.getParameter("newpass");
         gender=request.getParameter("gender");
         datepicker=request.getParameter("datepicker");

    }


    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

}

please help in issue

View Answers

November 1, 2012 at 11:26 AM


Insert form data into MS database

Follow these steps:

1)Go to the start->Control Panel->Administrative Tools-> data sources.

2)Click Add button and select the driver Microsoft Access Driver(*.mdb).

3)After selecting the driver, click finish button.

4)Then give Data Source Name and click ok button.

5)Your DSN will get created.

6) Restart your server and run your jsp/servlet code.

1)form.jsp:

<html>
<body>
<form method="POST" action="../ServletForm">
  <pre>
  User Id:    <input type="text" name="userId" size="20"></p>
  First Name: <input type="text" name="firstname" size="20"></p>
  Surname:    <input type="text" name="surname" size="20"></p>
  Address1:   <input type="text" name="address1" size="20"></p>
  Address2:   <input type="text" name="address2" size="20"></p>
  Town:       <input type="text"   name="town" size="20"></p>
  City:       <input type="text" name="country" size="20"></p>
  Zip code:   <input type="text" name="zipcode" size="20"></p>
              <input type="submit" value="Submit" name="B1"></p>
              </pre>
</form>
</body>
</html>

2)ServletForm.data:

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ServletForm extends HttpServlet{
  public void init(ServletConfig config) throws ServletException{
  super.init(config);
  }
  public void doPost(HttpServletRequest req, 
  HttpServletResponse res) throws ServletException,
  IOException{

  ResultSet rs;
  res.setContentType("text/html");
  PrintWriter out = res.getWriter();
  String uId = req.getParameter("userId");
  String fname = req.getParameter("firstname");
  String sname = req.getParameter("surname");
  String address1 = req.getParameter("address1");
  String address2 = req.getParameter("address2");
  String town = req.getParameter("town");
  String county = req.getParameter("country");
  String zipcode = req.getParameter("zipcode"); 
  try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =DriverManager.getConnection("jdbc:odbc:access");

  String sql =  "insert into emp_details values (?,?,?,?,?,?,?,?)";
  PreparedStatement pst = conn.prepareStatement(sql);
  pst.setString(1, uId);
  pst.setString(2, fname);
  pst.setString(3, sname);
  pst.setString(4, address1);
  pst.setString(5, address2);
  pst.setString(6, town);
  pst.setString(7, county);
  pst.setString(8, zipcode);
  int numRowsChanged = pst.executeUpdate();
  out.println(" Hello : ");
  out.println(" '"+fname+"'");
  pst.close();
  }
  catch(ClassNotFoundException e){
  out.println("Couldn't load database driver: " 
  + e.getMessage());
  }
  catch(SQLException e){
  out.println("SQLException caught: " 
  + e.getMessage());
  }
  catch (Exception e){
  out.println(e);
  }
  finally {
  try {
  if (connection != null) connection.close();
  }
  catch (SQLException ignored){
  out.println(ignored);
  }
  }
  }
}









Related Pages:
I cant get values in MS acces in tables
I cant get values in MS acces in tables   I got problem in sending values from servlet . * i am using ms acces * i cant display my values but der... sta = con.createStatement(); int i=sta.executeUpdate("insert
why cant i close this ??
why cant i close this ??  import java.util.Scanner; public class square { public static void main ( String [] args) { Scanner keyboard...("Thank you "); } } i should use while to get the square of the number entered
regarding ms acces database and servlet - JDBC
regarding ms acces database and servlet  hello there, i am trying to do a web application that makes use of a data base. I opted for ms access database, i could run java main programs(i e not servlets public static void main
Connect to MS Acces wothout using ODBC but JDBC - JDBC
Connect to MS Acces wothout using ODBC but JDBC  Hi, I want to connect my MS Access using JDBC but not ODBC. Please help me out. Thanks
fetch data from ms acces - Swing AWT
fetch data from ms acces  How do i fetch back AUTO generated key from MS ACCESS table after inserting data through the java panel.... Please Help Thanks in adv.  Hi Friend, Try the following code: import
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database... in register.jsp data is transferred into registration.java but i couldNOT get... .......WHY I CANT INSERT INTO TABLE (AUTHORS.ACCDB) IF U GIVE ANY EXAMPLE PLEASE
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database Follow... in register.jsp data is transferred into registration.java but i couldNOT get... .......WHY I CANT INSERT INTO TABLE (AUTHORS.ACCDB) IF U GIVE ANY EXAMPLE PLEASE I
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database... in register.jsp data is transferred into registration.java but i couldNOT get... .......WHY I CANT INSERT INTO TABLE (AUTHORS.ACCDB) IF U GIVE ANY EXAMPLE PLEASE
ms access
has to login . i already created ms access page and inserted values throught... and password " he has to login . i already created ms access page and inserted values...ms access  hey ,thanks for my question i have one question: now
ms access
has to login . i already created ms access page and inserted values throught... and password " he has to login . i already created ms access page and inserted values...ms access  hey ,thanks for my question i have one question: now
ms access
has to login . i already created ms access page and inserted values throught... and password " he has to login . i already created ms access page and inserted values...ms access  hey ,thanks for my question i have one question: now
ms access
has to login . i already created ms access page and inserted values throught... and password " he has to login . i already created ms access page and inserted values...ms access  hey ,thanks for my question i have one question: now
create MS Word in Java - Java Beginners
creates the word document having different paragraphs and two tables. i have sample code "Hello World!!! HAHAHAHAHA I DID IT!!" where we get this code everywhere. But i need to write more to the document like Table inserting values init
can i insert values into two tables by a query - JDBC
can i insert values into two tables by a query  hi all, can i insert values into two tables by a query Thanks Bala k
how to store array values into two different tables in java?
how to store array values into two different tables in java?  I have use 4/5 textboxes with same name(e.g.text1) and I get the values in a array and now I want to store these values in two different tables(i.e store 2 array
supplying values to in parameters of stored procedure in ms sql and displaying out parameters
supplying values to in parameters of stored procedure in ms sql and displaying out parameters  I have to execute following procedure ALTER PROCEDURE [dbo].[get_date] @codeId int, @vardate as datetime OUTPUT AS SELECT
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file  Hi am new to java. i need to create a dynamic web application. Am using eclipse IDE and Apache tomcat server. i need
how to acces file in c - WebSevices
how to acces file in c  How to acces file in c.... I have doubt on visual c++ ... how to create dialog control in visual c
accessing ms access through jsp
accessing ms access through jsp  i have 3 tables in my database employee,project,task if i put employee id the search field .i should get details from other table what all queries should i use in servlet file and i am using
MS-Access
MS-Access  I am trying to upload a image to ms-acess using jsp,and my...: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect ".I think i set... = con.prepareStatement("insert into user(name,address,image) values
how to get values for same column name from two different tables in SQL
how to get values for same column name from two different tables in SQL  how to get values for same column name from two different tables in SQL???? column name is emp_id loacated in these two tables company,employee
MS-ACCESS Query Problem - SQL
MS-ACCESS Query Problem  hi sir i have table which is initially... so i want to copy the Many records into Deleted Table by Selecting Student tables Course and Class wise Ex..Query like: if we execute this Query
sql query to get data from two tables
sql query to get data from two tables  how can i get the data from two different tables?   Hi Friend, Please visit the following link: JOIN Query Simple Query Thanks
MS Access - JSP-Servlet
MS Access  hello sir, i want to use MS.Access as my database..so my problem is how to connect MS Acces database with servlets ... thank you...   hai i m kaleeswaran ihave some idea to connect msaccess to servlet
how to get the values from dynamically generated textbox in java?
how to get the values from dynamically generated textbox in java?  I... to get and update this textbox values into both the tables(Xray,CTScan... textbox corresponding to the data. I want to get data from textboxes(generated
to get picture from ms access database by jsp-servlet....
to get picture from ms access database by jsp-servlet....  I have inserted a picture in ms access data base,,,how we can retrieve that picture by using jsp
get date picker values to a textbox
get date picker values to a textbox  I am using DatePicker to select date in a form in asp.net using c#. I need the picked data to get in to a textbox. Please help me soon
Joining tables using criteria
Joining tables using criteria  How do i join more than three tables and retrieve one column from parent table and count of unique values in a single column from child table,the joined tables must be maintain primary key
get values from Excel to database
get values from Excel to database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel file... express 2005. how can i do with java code
Get the list of tables in Sybase
Get the list of tables in Sybase   hello, How to get the list of tables in Sybase?   hii, Select name from sysobjects where type="...." it will give You list according to where clause
How to get a values - JSP-Servlet
How to get a values  Dear sir, I have one input text field and one submit button .Within one file how to get a values within a same jsp. Thanks and Regards Harini Veerapur.  Hi Friend, Try the following
Display the data to MS word
Display the data to MS word  i want help with displaying data on to ms word.When i click the button my web page my servlet should get the data from... for this then explain how i use it..a sample code to get it from db generating
Get values in drop down list
Get values in drop down list  Pls provide me jsp code to get values in drop down list from another table's field. my project has customer registration and company registration pages..... when i insert data in company
Get values from session to array
Get values from session to array  Hello I have stored my 2 dimensional array into session using C#.net. Now on aspx page i want to store same session variable into 2 dimensional array. And how to find count of session valaiable
Get values from session to array
Get values from session to array  Hello I have stored my 2 dimensional array into session using C#.net. Now on aspx page i want to store same session variable into 2 dimensional array. And how to find count of session valaiable
tables in oracle 10g
tables in oracle 10g  sir i have created a table in oracle 10g,i want to know where this table is stored and how can i move this table to another pc and insert values
sql query to get name,age,phone,address from tables t1,t2,t3,t4,t5 ..
sql query to get name,age,phone,address from tables t1,t2,t3,t4,t5 ..  ... by name"; i want for 12 tables : i want to fetch name age pwd phone address from 12... , address FROM t1 order by name"; this is for 2 tables : query ="SELECT t.name
How to Access MS Access in jar.
to access it via Code or is their any alter-native?? Do i need any Driver to do this ... i m able to access a Ms-access via JDBC but cant find the file wen...How to Access MS Access in jar.  how do i access my Ms-Access file
how to access the MS ACCESS database with java
="delhi"; int i=st.executeUpdate("insert into user(name,address) values...how to access the MS ACCESS database with java   how to access the MS ACCESS database with java how can we insert,delete,update,search records
inserting picture in ms access
inserting picture in ms access  hi i am sanatan, how to insert picture in ms access by jsp.   <%@page import="java.sql.*,java.io.*"%>... into user(name,address,image) values(?,?,?)"); pre.setString(1
I need to join three tables and return data that may not be in all three tables
do not get all the students, I only get the students that are in all three tables...I need to join three tables and return data that may not be in all three tables  How do I join three tables and return information even
How to get a values - JSP-Servlet
How to get a values  Dear sir, I have a one form... getting a null value aprt from a attachmented file,so how to get a other values... When i submit a form ,inother jsp i.e
applet connected to table in MS Access database
applet connected to table in MS Access database   i have connected my java code with the MS access database and this is my code, can anyone tell me... or update. stmt.execute("drop table COFFEES");//if exists, drop it, get
Nest tables within tables
Nest tables within tables  Can I nest tables within tables
this is my code but i cant able to run it wt is the problem
this is my code but i cant able to run it wt is the problem  import java.io.*; class createthread { int thread=4,i; class thread1 extends createthread { public void run() { for(i=0;i
this is my code but i cant able to run it wt is the problem
this is my code but i cant able to run it wt is the problem  import java.io.*; class createthread { int thread=4,i; class thread1 extends createthread { public void run() { for(i=0;i
updation problem during transaction to ms-access
updation problem during transaction to ms-access  Hey friends I am a beginner to java,and my problem is related to updation query in ms... of that corresponding id, values will get displayed into the form. Then you can
updation problem during transaction to ms-access
updation problem during transaction to ms-access  Hey friends I am a beginner to java,and my problem is related to updation query in ms... of that corresponding id, values will get displayed into the form. Then you can
updation problem during transaction to ms-access
updation problem during transaction to ms-access  Hey friends I am a beginner to java,and my problem is related to updation query in ms... of that corresponding id, values will get displayed into the form. Then you can
updation problem during transaction to ms-access
updation problem during transaction to ms-access  Hey friends I am a beginner to java,and my problem is related to updation query in ms... of that corresponding id, values will get displayed into the form. Then you can

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.