JDBC Connection and Registration

JDBC Connection and Registration

  1. How to create a JDBC connection to MSAccess.
  2. How to create a table in MSAccess Manually, like going and opening MSAccess and creating column names.
  3. How to store data into the above manually created database from Servlets program.
  4. how to retrieve user data, which is already stored in database.
  5. How to validate user registration.

Thanks in advance.. :-)

View Answers

September 13, 2012 at 1:08 PM

JDBC MS Access Database Connectivity:

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 compiler and compile your java with jdbc code.. It will create table in MS access database. Here student is our dsn.

import java.sql.*;

public class CreateTable {
  public static void main(String[] args) throws Exception {
    Connection conn = DriverManager.getConnection("jdbc:odbc:student");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Statement st = conn.createStatement();
    st.executeUpdate("create table employee (empid int,empname varchar(30));");
    System.out.println("Table is created successfully!");
    st.executeUpdate("insert into employee (empid,empname ) values (1,'Roseindia')");
    System.out.println("Data is inserted successfully!");
    st.close();
    conn.close();
  }
}

September 13, 2012 at 1:17 PM

Create table in MS Access Database manually.

Follow these steps:

1)Open your MS Access Database. You will get a prompt box, select your dsn from there.

2)Then double click the Create table in Design view.

3)Fill out the details in the "Field Name" column and the "Data Type" column.

4)Click the "Save" icon, enter the table name ("Individual"), and click "OK".

5)When prompted to set a primary key, click "Yes", if you want to create, otherwise click No. (A primary key ensures that the data in this column is unique - no two values can be the same. This is important for when you need to select or reference data from this column).


September 13, 2012 at 1:25 PM

Servlet Program to insert the data into database table Individuals which consists of two fields name and address(suppose).

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

public class DataInsertion extends HttpServlet{
  public void doGet(HttpServletRequest request,  HttpServletResponse response)throws 
  ServletException, IOException{  
  response.setContentType("text/html");
  PrintWriter out = response.getWriter();
  try{
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Connection conn = DriverManager.getConnection("jdbc:odbc:student");
  Statement statement = conn.createStatement();
  String query = "insert into Individual values('roseindia', 'Rohini')";
  int i = statement.executeUpdate(query);
  if(i!=0){
  out.println("The record has been inserted");
  }
  else{
  out.println("Sorry! Failure");
  }
  statement.close();
  }
  catch (Exception e){
  System.out.println(e);
  }
  }
}

September 13, 2012 at 1:29 PM

Servlet example that fetch the data from the table 'Individual' and display the data on the browser.

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

public class ServletFetchingDataFromDatabase extends HttpServlet{
  public void doGet(HttpServletRequest request, HttpServletResponse 
  response)throws ServletException, IOException{
  response.setContentType("text/html");
  PrintWriter pw = response.getWriter();
  try{
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Connection conn = DriverManager.getConnection("jdbc:odbc:student");
  Statement st = connection.createStatement();
  ResultSet rs = st.executeQuery("Select * from Individual");
  while(rs.next()){
  pw.println("Name" + " " + "Address" + "<br>");
  pw.println(rs.getString(1) + " " + rs.getString(2) + "<br>");
  }
  }
  catch (Exception e){
  pw.println(e);
  }
  }
}

Validate User Registration









Related Tutorials/Questions & Answers:
JDBC Connection and Registration
JDBC Connection and Registration   How to create a JDBC connection... stored in database. How to validate user registration. Thanks in advance.. :-)   JDBC MS Access Database Connectivity: Follow these steps: 1)Go
JDBC connection pooling
JDBC connection pooling  What is Connection pooling
Advertisements
jdbc connection
"); Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1...jdbc connection  How to Submit data????   <%-- view... { Class.forName("com.mysql.jdbc.Driver"); Connection con = (Connection
JDBC connection
JDBC connection  ![alt text][1]I got exception in Connecting to a MySQL Database in Java. The exception is ClassNotFoundException:com.mysql.jdbc.Driver wat is the problem
Java jdbc connection
Java jdbc connection  Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection
j2me jdbc connection - JDBC
j2me jdbc connection  hello, whn i m importing sql package in mine midlet(tried for both javax.sql.* and java.sql.*;)..itz nt accepting it... hw to get connected to database?????.... plz help me out
Java Jdbc connection
Java Jdbc connection  What are the steps involved for making a connection with a database or how do you connect to a database
jdbc odbc connection
jdbc odbc connection  i need a program in java which uses a jdbc odbc connection   Hi, You can create odbc datasource on your windows computer and then access in your Java program.ADS_TO_REPLACE_1 Read the JDBC ODBC
jdbc connection issues
jdbc connection issues  Hello. kindly pls help in this issue...i have created 11 jsp form wit some attributs in it also created 11 tables... tables with only one jdbc connection program...if possiable pls post a sample code
connection pooling - JDBC
. In JDBC connection pool, a pool of Connection objects is created...++) { gObjPool.addObject(); } Connection connection = java.sql.DriverManager.getConnection("jdbc...connection pooling  how to manage connection pooling?   Hi
Java-Connection Pool - JDBC
Java-Connection Pool  How can I create a connection pool. My database... is Weblogic 8. Which is the best approach to create a connection pool? ...{ public static void main(String[] args){ Connection con = null; String url
Connection to jdbc - Java Beginners
Connection to jdbc  I need to populate a listbox in jsp with values from Postgresql JDBC. i used the following code... but its not working... can u suggest me with the correct solution. my.jsp my form
connection with xslx - JDBC
connection with xslx  hai to all i am not able to connecting to xlsx(2007 excel file) using jdbc?please help me?  Hi Friend, Please visit the following links: http://www.roseindia.net/tutorial/java/poi
JDBC connection and SQL Query - JDBC
JDBC connection and SQL Query  Hi, I'm reading a all files one after the other in a directory in java. storing the values in an array of string each time. Now I'm trying to execute a query to insert those values into an oracle
Java Jdbc connection
Java Jdbc connection  What are the two major components of JDBC
choosing best jdbc connection - JDBC
choosing best jdbc connection  among the four types of jdbc which one... is the best type of Jdbc JDBC Net pure Java Driver A native-protocol pure Java driver converts JDBC technology into the network protocol
Java Jdbc connection
Java Jdbc connection  What is the use of Class.forName
JDBC Connection Pool
JDBC Connection Pool In this section we will learn about JDBC Connection Pool... application will give you improved performance if you use the JDBC Connection pooling. What is JDBC Connection Pool? The database connection is expensive
java database connection - JDBC
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connect =DriverManager.getConnection("jdbc:odbc:access"); pstm=connect.prepareStatement("insert into data
Database Connection - JDBC
Database Connection  In java How will be connect Database through JDBC?  Hi Friend, Please visit the following link: http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml Thanks
Java-Connection Pool - JDBC
Java-Connection Pool  How can I create a connection pool. My database is MS SQL server 2000(username-sa, pwd-admin) and my application server is Weblogic 8. Which is the best approach to create a connection pool? Kindly help
JDBC connection
JDBC connection       The JDBC... we illustrates you JDBC url connection. The current Tutorial helps you to understand JDBC connection. The code explains you   how
Connection pooling - JDBC
Connection pooling  what is meant by connectio pooling and how...;connection pooling concept basically deals with the pool of object. In every... to the container about max and min connection object in the pool
problem in jdbc connection
problem in jdbc connection  when i am trying to insert into apache derby databse using java in netbeans an exceprion is thrown at run time like this:- java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver....what
Server DB connection - JDBC
get it to work. If you have any sample code for getting connection please
REQ for connection b/w jdbc and oracle database
REQ for connection b/w jdbc and oracle database    REQ for connection b/w jdbc and oracle database    The Java classes to connect... (OCI or Thin) through the JDBC connection URL. Here are some connection URL
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
JDBC connection closed.. - Java Beginners
JDBC connection closed..  if the connections r closed..the values... the connection (jdbc) is closed)   Hello, As i know after connection closed you will get the value.I tried your question and found
jdbc connection to java program code - JDBC
jdbc connection to java program code  i want a simple java program that which communicates with oracle database like creating table,insert values and update records in database and show in program output? please take a simple
Could not establish the connection to oracle - JDBC
to use: Connection conn = DriverManager.getConnection("jdbc:oracle:oci8... to use: Connection conn = DriverManager.getConnection ("jdbc:oracle:thin... oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection("jdbc:oracle
open a connection to a database with exclusive mode with JDBC
open a connection to a database with exclusive mode with JDBC  Is possible to open a connection to a database with exclusive mode with JDBC
open a connection to a database with exclusive mode with JDBC
open a connection to a database with exclusive mode with JDBC  Is possible to open a connection to a database with exclusive mode with JDBC
JDBC-Odbc Connection
JDBC-ODBC Connection       JDBC-ODBC Connection is a JDBC driver that translates the operation... help you in explaining JDBC Odbc Connection in Java. The code explains you
Connection pool in Tomcat 6 - JDBC
Connection pool in Tomcat 6  Hello Everybody, I am trying to implement connection pooling in Tomcat 6 and MySQL 5.0.41 with mysql-connector... : org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver
A JDBC Connection Pooling Concept
; } JDBC Connection Pooling JDBC Connection pooling is similar to any other object pooling. Connection pooling is very useful for any application which uses... into the pool.  An example of JDBC connection pooling is given below. to run
JDBC ODBC Connection In Java
JDBC ODBC Connection In Java In this section we will read about the various aspects of JDBC ODBC such as, JDBC-ODBC bridge, JDBC ODBC connection, how... is sun.jdbc.odbc.JdbcOdbcDriver.ADS_TO_REPLACE_1 JDBC ODBC Connection To Connect
Connection pool in Tomcat 6 - JDBC
Connection pool in Tomcat 6  Hi All, Any one please tell me how to implement connection pooling in Tomcat 6 and MySQL 5.0.1b. Thanks, Ramarao  Hi Friend, Please visit the following link: http
Problem to get connection from DAO class to JDBC
Problem to get connection from DAO class to JDBC  package controller... ConnectionProvider { private static Connection con=null; //static Connection..."); }catch(Exception e){} } public static Connection getCon(){ return con
Jdbc Mysql Connection Url
JDBC Mysql Connection Url      ... JDBC Mysql Connection. In this program, the code explain the JDBC url and string connection that helps you in connecting between url and database. For this we
connection
connection   how to make multiple database connection using jdbc
connection - JDBC
JDBC connection timeout
JDBC connection timeout       The Tutorial describe you a JDBC Connection timeout. In this program, we... The code include a class JDBC Connection Timeout, inside the main method we include
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:student"); Statement st=con.createStatement
Database connection sql server 2005 - JDBC
Database connection sql server 2005  Hi all i am developing an application in struts and i need to connect database for that application using sql server 2005.. can anyone tell me how to make database connection ..plz help me
registration application
registration application  How to develop a registration application in struts which has seperate file for database connection and data checking and form and action
JDBC Connection code to connect servlet with SQL Server 2008
JDBC Connection code to connect servlet with SQL Server 2008  Please... support for JDBC 4.0. i try Avery thing but i m not success so please ans me . My connection code is static Connection con; static Statement st; static
Connection using Jdbc-odbc bridge Driver
Connection using JDBC-ODBC bridge driver JDBCExample.java... program, Jdbc-Odbc bridge driver create connection between java application...=DriverManager.getConnection("jdbc:odbc:datastud"); --In the above code, connection class
JDBC Connection Example
; } JDBC Connection Example JDBC Connection is an interface of java.sql.*;  package. An connection object represents a connection with specific database.... Connection con=DriverManager.getConnection("jdbc:mysql://localhost
Jdbc Get Connection
JDBC Get Connection       The JDBC Get Connection is the mean of establishing... help you to understand a code from JDBC Get Connection. The code describe you
Connection
Connection  What is Connection

Ads