JDBC Connection and Registration

Ads
 

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

Ads









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
"); 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
Advertisements
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
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
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
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
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
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
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-Odbc Connection
JDBC-ODBC Connection       JDBC-ODBC Connection is a JDBC driver that translates the operation... in explaining JDBC Odbc Connection in Java. The code explains you a how creation
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. JDBC ODBC Connection To Connect the JDBC and ODBC
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
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 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
connection
connection   how to make multiple database connection using jdbc
JDBC Connection Example
; } JDBC Connection Example JDBC Connection is an interface of java.sql.*;  package. An connection object represents a connection with specific database. A single application can have more than one Connection object with a single
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
Jdbc Get Connection
JDBC Get Connection       The JDBC Get Connection is the mean of establishing... to understand a code from JDBC Get Connection. The code describe you connection
Jdbc Mysql Connection String
JDBC Mysql Connection String   ... public final String connection = "jdbc:mysql://localhost:3306/komal"...(connection, user, password); System.out.println("Jdbc Mysql Connection String
connection
the connection with the available port on the host machine: import java.net.... the connection was not established. Predict the output of the preceding code. Explain why the connection cannot be established
jdbc
jdbc  Write a web based student registration application where the students can register online with their enrollment no. You are required to use JSP, Servelet and JDBC
JDBC
JDBC  in class.forname which driver name we are writing for the connection from jdbc to sqlserver 2008
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.  please provide online quiz program coding using jsp, jdbc...").newInstance(); Connection connection = DriverManager.getConnection("jdbc:mysql
jdbc
jdbc  i had written jdbc connection in method and i need to get connection in another class?   import java.sql.*; class DatabaseConnection{ public static Connection getConnection() throws Exception { String
Correctly Open and Close database connection
; } Completely Open and Close A Database Connection Database Connection... and close database connections properly. If any database connection is open... , temporary tables all are are engaged. To release the connection object it is very
jdbc
jdbc define batch updates  define batch updates?exp   JDBC... to the database in a single request using connection object. The advantage of batch... links: http://www.roseindia.net/jdbc/Jdbc-batch-update.shtml http
JDBC
JDBC save a data in the database  I need a code to save a data in the database can anyone help?   The given code set up the connection between java and mysql using JDBC and saves the data into the database. import
JDBC
the connection between java and mysql using JDBC and saves the data into the database...!"); Connection con = null; String url = "jdbc:mysql://localhost:3306/"; String db...JDBC code to save a data in the database  I need a code to save
jdbc
using jdbc connection   import java.sql.*; public class CreateTable { public static void main(String[] args) throws Exception { Connection conn = DriverManager.getConnection("jdbc:odbc:student"); Class.forName
DataBase Connection
DataBase Connection  How to connect java and Oracle 10g? Tell me Jdbc connection

Ads