Home Answers Viewqa JDBC unable to retrive the data from mysql using servlet using jdbc driver

 
 


Ajay Bhushan.B
unable to retrive the data from mysql using servlet using jdbc driver
1 Answer(s)      a year and 7 months ago
Posted in : JDBC

Hi, i have a servlet program..to verify the login and redirect to correct html page on verification. public class LoginServlet extends HttpServlet implements javax.servlet.Servlet {

 public void doPost (HttpServletRequest request, HttpServletResponse response) 
 throws ServletException,IOException
 {
    // Get the requested name and the output writer. 
    PrintWriter out = response.getWriter (); 
    String username = request.getParameter("UserName");
    String password = request.getParameter("Password");

    //Used to instantiate a connection
    Connection con = null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbName = "rapax";
    String driver = "com.mysql.jdbc.Driver";
    String userName = "root"; 
    String password1 = "ajay12";
    Statement stmt = null;
    ResultSet rs = null;
    try 
    {   
        try
        {
              Class.forName(driver).newInstance();
        }
        catch(InstantiationException e)
        {
        }
        catch(IllegalAccessException e)
        {
        }
        con = DriverManager.getConnection((new

StringBuilder()).append(url).append(dbName).toString(),userName,password1); System.out.println("Connected to the database"); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT * FROM login where

username="+username+" and password="+password); // displaying records if(rs.next()) { String uname=rs.getObject(1).toString(); String pwd=rs.getObject(2).toString();

response.sendRedirect("http://localhost:8080/sessionAction.html"); }
else { out.println("\n\nInvalid Login\n"); rs.close(); response.sendRedirect("http://localhost:8080/login.html"); } // throw new IOException(new IOException("Error")); }

    catch (SQLException e) 
    {

    } 
    catch (ClassNotFoundException e) {

    } 

    finally 
            { 
        try 
              {        


                                   if(rs!=null)
                         {

                       try{

                           rs.close();
                                }
                                catch(NullPointerException e)
                {
                                }
                         }
            rs = null;
                            if(stmt!=null)
                            {
                              try
                              { 
               stmt.close();
                              }
                              catch(SQLException e)
                              {
                              }
                             }
                             stmt = null;
                            if(con!=null)
                            {
                             try
                             {
                   con.close(); 
                             }
                             catch(NullPointerException e) 
                             {
                             }
                            }


            con = null;
        }
         catch (SQLException e)
                     {

                 }
        out.close();
    }
}
public void doGet(HttpServletRequest request,HttpServletResponse response) throws   

  ServletException,IOException
    {
                doPost(request,response);
    }

}

.i am unable to redirect..here is the code..pls help me THANK YOU

View Answers

October 25, 2011 at 12:38 PM


Please visit the following link:

http://www.roseindia.net/jsp/loginbean.shtml









Related Pages:
unable to retrive the data from mysql using servlet using jdbc driver
unable to retrive the data from mysql using servlet using jdbc driver  Hi, i have a servlet program..to verify the login and redirect to correct... Connection con = null; String url = "jdbc:mysql://localhost:3306
Retrive the data from the table in data base using jdbc
Retrive the data from the table in data base using jdbc  Retrive the data from the table in data base using jdbc   JDBC Tutorials
retrive data from database using jsp in struts?
retrive data from database using jsp in struts?   *search.jsp* <... searchProduct(SearchDTO sdto) { String query="select * from product...()); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver  .... so, can any one help me without creating DNS we should retrieve data from excel using ODBC.plz help me guys..........   Follow these steps: Open Data
get info from mysql using jsp and servlet
the user to key in their email address from mysql database by using servlet and jsp too...get info from mysql using jsp and servlet  HELLO! I wanna create...; String url = "jdbc:mysql://localhost:3306/"; String dbName = "register"; String
image retrive into DataBase - JDBC
shows you how to retrieve image from database using a servlet and then show..., Retrieving image from database is easy task. JDBC provides all the necessary API... and then: a) Show it to your using servlet b) Save on your hard disk. Here
Connecting to the Database Using JDBC and Pure Java driver
engine we are using MySQL database server and MM.MySQL Driver... this driver to make connections to MySQL server from both Java... and for making connection we are using MM.MySQL JDBC Driver
Request URl using Retrive data from dtabase
Request URl using Retrive data from dtabase  Using With GWT the user can create an event. In the create page, we have three buttons. Save as draft... the contents from the db based on the event id. But this jsp url should
Expport data into CSV File using JDBC in Servlet
into CSV File using JDBC in Servlet   ... into CSV file using JDBC in Servlet. We have created  file "JdbcCsvFile.java" to export data from database in to CSV file. Brief
how to retrive the particular data from database in php with mysql?
how to retrive the particular data from database in php with mysql?  ..._db("samp", $con); $Name=$_POST['unames']; $data=mysql_query("SELECT * FROM tbl_sample where Name='$Name'"); /*$info=mysql_fetch_array($data);*/ while
MySQL Driver for JDBC - JDBC
MySQL Driver for JDBC  Sir, I have started reading your JDBC tutorial...... Example."); Connection conn = null; String url = "jdbc:mysql://localhost:3306   Hi,Please download the driver from http://www.mysql.com/products/connector
store and retrive image from database - JDBC
store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image... url = "jdbc:mysql://localhost:3306/"; String dbName = "databasename
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes...;body> &lt;% try {</p> <p>String connectionURL = "jdbc
insert and retrive data and time - SQL
insert and retrive data and time  hello everybody . Is there any...{ public static void main(String args[]){ String url = "jdbc:mysql://localhost... static void main(String args[]){ String url = "jdbc:mysql://localhost:3306
GWT -- retrive the data from Database
GWT -- retrive the data from Database  the user can create an event... button, you have to create a dynamic jsp which should read the contents from... it will be sharable in the social media sites. I need using GWT
Retrive data from databse to a text field - Java Server Faces Questions
Retrive data from databse to a text field  Hi, Can you give me a source code to rertrve data from Mysql databse to a text field using JSF.....by selecting option from a dropdown option
Jdbc connectivity by type 4 driver
Jdbc connectivity by type 4 driver  I have done a code with database connectivity with driver 4,it copiles,but while running it is showing...=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521","system","123
Displaying Mysql clob data using Servlet
Displaying Mysql clob data using Servlet .In this Section, we will display a clob data from a table of database using servlet. A CLOB is a Character Large... any portion of the CLOB data. 2.Equallity of 2 CLOBs can  be check by using
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp   the user can create an event. In the create page, we have three buttons. Save as draft... the contents from the db based on the event id. But this jsp url should be a public
unable to connect database in java
to connect database with my application by using java but i am unable to connect... i was using this code.... try { Driver d=(Driver)Class.forName...=DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=E:/Final Project
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp  The user can create an event. In the create page, we have three buttons. Save as draft... the contents from the db based on the event id. But this jsp url should be a public url
No suitable driver found for jdbc:mysql://localhost:3306/TEST
No suitable driver found for jdbc:mysql://localhost:3306/TEST  hii, I have wrietten web project using jsp and hibernate but its not working. ava.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/TEST
unable to connect database in java
to connect database with my application by using java but i am unable to connect... i was using this code. try { Driver d=(Driver)Class.forName...=DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=E:/Final Project
Deleting Mysql Clob data using servlet
Deleting  Mysql Clob data using servlet In this Section, we will discuss about how to delete a Clob data from a database table using servlet. A CLOB...;   con =DriverManager.getConnection ("jdbc:mysql
How to retrive database information using servlet and disply in table format in browser
How to retrive database information using servlet and disply in table format in browser  Hi, any one send code how to retrive the data base information in table format in web browser
Data retrieve from mysql database
Data retrieve from mysql database  Hi sir, please give some example... from the dropdown, related data will get displayed on the textboxes. Here we have...("name").toString(); String data=""; Connection conn = null; String url = "jdbc
Connection using Jdbc-odbc bridge Driver
Connection using JDBC-ODBC bridge driver JDBCExample.java... database is ready to connect using JDBC-ODBC bridge driver. For this you have...;); --In this program "forName()" function is used to load the JDBC-ODBC bridge driver
how to connect j2me program with mysql using servlet?
how to connect j2me program with mysql using servlet?  my program... the response from the servlet page. DataInputStream... = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+db,username,password
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... to populate the first one, and then how to send the data off to a servlet and preform...").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql
How to retrive a particular record from database in php with mysql?
How to retrive a particular record from database in php with mysql?  Am using phpMyAdmin Database.In mysql database having 10 records. The field... record based on username and password. I dont know how to retrive in php with mysql
unable to compile class file - JSP-Servlet
:mysql://192.168.10.211:3306/";; String db = "amar"; String driver...unable to compile class file  I wrote database connection in jsp file... in that dropdown list box.   Hi, dynamic bombobox in servlet
Dynamic loading of Combo box list using servlet - JSP-Servlet
, retrive it in a servlet, By using this value communicate to the data base...(); Connection con = null; String url = "jdbc:mysql://192.168.10.211:3306...Dynamic loading of Combo box list using servlet  I have the category
Inserting Mysql CLOB data using Servlet
Inserting Mysql CLOB data using Servlet In this Section, we will insert "clob" data using "servlet". A CLOB is a Character Large Object... portion of the CLOB data. 2.Equallity of 2 CLOBs can  be check by using equals
java- jdbc with type 4 driver
and Register the JDBC driver:*** DriverManager.registerDriver(new...("oracle.jdbc.driver.OracleDriver"); 3) Connect to database:*** a) If you are using oracle oci driver... and root is the username and password. b) If you are using oracle thin driver,you
Unable to call .jrxml file from jsp
Unable to call .jrxml file from jsp  Hi, I am doing web application in jsp. To create report I have used ireport and interated with neatbeans using...; JasperDesign jasperDesign; try { String connectionURL = "jdbc:mysql://localhost
Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my database.. Eg- text1,text2,text3,....,upto text30... i want to export this data
mysql jdbc connectivity
mysql jdbc connectivity  i want to connect retrieve data from mysql using jdbc
retrive mails - Java Beginners
retrive mails   hi how to retrive mails using mysql in java not using pop3 or imap directly from database i am using dbfile system in james server.header should be store in database and message in file system thanks bala
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data...= driver=oracle.jdbc.driver.OracleDriver url=jdbc:oracle:thin:@192.168.100.20... = getProperties(); System.out.println(aProps.getProperty("driver
javascript for textbox or prompt using servlet - JSP-Servlet
("FirstNameLastNameAddressEmail"); Connection con = null; String url = "jdbc:mysql...javascript for textbox or prompt using servlet  Dear sir I am writing script in servlet,so prompt() is not working here so please help me
jdbc
jdbc  how can i store the image file and retrive the images from the database using java with querys also   import java.sql.*; import... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root
retrive data from oracle to jsp
retrive data from oracle to jsp  i am a beginer in jsp so please help... cost and manager name and storing it in the data base. in search proj fiel...(); psmt= conn.prepareStatement("select * from CR_EMPLOYEE_DETAILS
how to insert data from database using oops concepts - Development process
how to insert data from database using oops concepts  Hi, How to insert data from database using oops based concepts.please write the code... = "jdbc:mysql://192.168.10.211:3306/"; public static String db = "mysql
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down list box in jsp  hai, im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown list box
Unable to bind to a hashmap from jsp using spring tags - Spring
Unable to bind to a hashmap from jsp using spring tags  Hi, I am unable to bind a hashmap from my jsp page. Here is what i want to do: I have... text box where user need to enter data. (It is to be noted that the size
JDBC Example with MySQL
establishing the connection with MySQL database by using the JDBC driver, you... for transferring data between an database using MySQL data types and a application using... JDBC Example with MySQL      
javax. servlet.Servlet Exception: Initialization failed, Unable to get DB connection - JSP-Servlet
com.mysql.jdbc.Driver url jdbc:mysql://localhost/blackbook ls... { ServletContext ctxt=getServletContext(); //Getting the Driver class name from context..."); Class.forName(driverClassName); //Getting the JDBC URL from context parameter String
how to insert and retrieve an image from mysql using java - Java Beginners
how to insert and retrieve an image from mysql using java  how to insert and retrieve an image from mysql using java?  Hi friend, Code.... */ String connectionURL = "jdbc:mysql://localhost:3306/mahendra
database connectivity using mysql
seconds) I am using Netbeans 5.5, mysql server 5.0, to get data from table...[]) throws SQLException { try { String connectionURL = "jdbc:mysql...database connectivity using mysql  java file: eg1.java package eg
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create... and insert those inputs into database using JDBC.   Here is a jsp code...("jdbc:mysql://localhost:3306/roseindia", "root", "root"); Statement

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.