About jsp and mysql

Hi all,
Requirement:
I have a front end in which there are 3 fields name,age,status when ever I enter values these should be stored in mysql db.and here in status I have check constraint it should be either 'Active' or 'Inactive'
when ever I enter Active into status text field It should store as 1 in db
when ever I enter Inactive into status text field it should store as 0 in db .
How to acheive this please give me some suggestions
Thanks in Advance....

Also, rather than submit the page on clicking the 'save' button, have an onClick() attribute added to the save button that calls a javascript function. In the javascript function, do some basic client side validation before allowing the function to submit to the server. Example: name cannot be empty, age cannot be empty, age must be a number (no letters), either active or inactive must be checked.

Similar Messages

  • Need a host free about jsp and mysql in order to test my subject project.

    Please show me a address host free . I need it to test my project. Thank so much

    Try Google Apps. Totally free.
    - Saish

  • JSP and MySql Connectivity in Fedora core 4

    Dear all,
    We are developing software using JSP and MySql on Fedora Core 4 platform and are unable to find the connectivity for JSP and MySql. Can anybody help....

    Dear all,
    We are developing software using JSP and MySql on Fedora Core 4 platform and are unable to find the connectivity for JSP and MySql. Can anybody help....

  • Unable to connect JSP and MySQL

    Hi, I am new to this forum
    I've started developing web pages using JSP
    I've the problem connecting JSP and MySQL database. I've created the page that retrive records from mysql table. But the connection fail to access to database it gives me this error:
    org.apache.jasper.JasperException: Exception in JSP: /retreive_book.jsp:15
    The code is:
    12: <%
    13: //Class.forName("com.mysql.jdbc.Driver").newInstance();
    14: Class.forName("org.gjt.mm.mysql.Driver");
    15: connection = DriverManager.getConnection(connectionURL,"","");
    16: statement = connection.createStatement();
    17: rs = statement.executeQuery("SELECT * FROM books_detail");
    18: %>
    And the connectionURL parameter has this value:
    String connectionURL = "jdbc:mysql://localhost:3306/books?username=;password=";
    root cause msg is:
    java.sql.SQLException: Invalid authorization specification: Access denied for user 'nobody'@'localhost' (using password: NO)
    Please can anyone help me. It is 3 days now trying to do that but not succeded yet

    Hi
    Yes It is true that my MySQl installation its username is root. So how should put that in the url. Cause I did that but it didn.t work
    String connectionURL= "jdbc:mysql://localhost:3306/books?username=root;password=";
    If I write in that manner is it correct for root username or should I put a single quote
    Thanks

  • Syntac error in JSP and MySQL

    HI guys,
    I have been facing another problem. The codings below. Worked well with my JSP and Access database.
    Then I transfered my database to MySQL and it gives out syntax error in my SQL statement.
    CODE1:
         sql = "SELECT Week, SUM (Total_Inspected) AS ins, SUM (Total_Rejected) AS rej, SUM (Total_Accepted) AS acc, SUM (DPPM) AS dpp, SUM (Yield) AS yeel FROM Calc_Data WHERE MONTH(Inspect_Date) ="+bulann+" GROUP BY Week";
         ResultSet rs = stm.executeQuery(sql);
    CODE2:
    String query   = "SELECT ID, Model, Lot_No, Lot_Qty, Inspected_By, Reject_Desc, Area_Concerned, Location, Remark FROM OQA WHERE Customer = '"+customer+"' AND Inspect_Date =#"+tarikh+"#";
    ResultSet rs   = stmt.executeQuery(query);

    Whenever you have this type of problem, the easiest
    solution is to take the sql and try running it
    directly. For MySQL, you can either use the
    command-line client, or there are a few graphical
    clients that can handle it. Just type in the query,
    run it, and let the database itself tell you what the
    error is.
    In any case, you probably won't find much useful
    advice on a JSP forum, esp. since the problem has
    absolutely nothing to do with JSP.Indeed - I agree with this. - MOD

  • Problems with JSP and MySql bean.

    Hi,
    I'm new to JSP and I'm having some problems with it. I'm trying to do a simple login where a java class (bean?) handles the SQL injektion. I have deployed the page on tomcat and it works fine, except that the sqlinjektion does basically nothing. I have installed the mysql driver. I think there is something wrong with the java class, or the way im calling it. It does not produce any error. But its like it would never actually process the java code, because ive tried to append things to error string to see what is going on, nothing happens. everything stay null, no exceptions are thrown. If I implement the code to JSP itself, it does load the driver and print exception that there is no connection to database (which is correct). What am I missing? Code follows:
    the sqlhandler:
    public abstract class SqlInjektor {
         private static String Database = "*****";
         private static String serverName = "localhost:3306";
         private static String usrName="******";
         private static String passw="******";
         * @return Connection
         public static Connection createConnection(String error){
              Connection mySqlCon = null;
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception E){
                   PrintWriter out = response.getWriter();
                   out.println("lol");
              String url = "jdbc:mysql://" + serverName + "/" + Database + "?user=" + usrName + "&password=" + passw;
              try{
                   mySqlCon = DriverManager.getConnection(url);
              catch (Exception E){
                   E.printStackTrace(System.out);
              return mySqlCon;
         * Metodi saa sy�tteen��n SQL komennon, jonka se suorittaa sek� palauttaa komennon tulokset.
         * @param command
         * @return ResultSet
         public static ResultSet querySQL(String command,String error, Connection con){
              ResultSet rs = null;
              try{
                   Statement stmt = con.createStatement();
                   rs = stmt.executeQuery(command);
              catch(Exception E){
                   E.printStackTrace(System.out);
              return rs;
    the jsp page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page isErrorPage="false" %>
    <%@ page import="java.sql.*" %>
    <%@page import="ot3.User"%>
    <%@page import="ot3.SqlInjektor"%>
    <%@page import="Javax.servlet.jsp.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>vastaanotto</title>
    </head>
    <body>
    <%!      String id;
         String password;
         String error = new String("Error!\n");
         User user;
    %>
    <%      user = new User();
         session.putValue("currentUser",user);
         id = request.getParameter("authName");
    password = request.getParameter("Password");
         Connection conn=null;
         ResultSet rs=null;
         conn = SqlInjektor.createConnection(error);
         if(conn!=null){
              out.println("conn ok!");
              rs = SqlInjektor.querySQL("SELECT * FROM user WHERE id='" + id +"' AND password='" + password+"' COLLATE latin1_bin;",error,conn);}
         try {
              if (rs!= null && rs.next()){
                   user.setID(rs.getInt("id"));
                   user.setName(rs.getString("name"));
                   user.setPassword(rs.getString("password"));
                   user.setClearance(rs.getInt("clearance"));
                   if(rs.getString("addedby")!=null)
                        user.setAdder(rs.getInt("addedby"));
                   if(rs.getString("lastmodifier")!=null)
                        user.setModifier(rs.getInt("lastmodifier"));
                   rs.close();%>
                   ONNISTU!
              <%}
              else {
                   out.println(error);     
         } catch (SQLException e) {
              out.println(e.getMessage());
         }%>
    </body>
    </html>

    Hi,
    I'm new to JSP and I'm having some problems with it. I'm trying to do a simple login where a java class (bean?) handles the SQL injektion. I have deployed the page on tomcat and it works fine, except that the sqlinjektion does basically nothing. I have installed the mysql driver. I think there is something wrong with the java class, or the way im calling it. It does not produce any error. But its like it would never actually process the java code, because ive tried to append things to error string to see what is going on, nothing happens. everything stay null, no exceptions are thrown. If I implement the code to JSP itself, it does load the driver and print exception that there is no connection to database (which is correct). What am I missing? Code follows:
    the sqlhandler:
    public abstract class SqlInjektor {
         private static String Database = "*****";
         private static String serverName = "localhost:3306";
         private static String usrName="******";
         private static String passw="******";
         * @return Connection
         public static Connection createConnection(String error){
              Connection mySqlCon = null;
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception E){
                   PrintWriter out = response.getWriter();
                   out.println("lol");
              String url = "jdbc:mysql://" + serverName + "/" + Database + "?user=" + usrName + "&password=" + passw;
              try{
                   mySqlCon = DriverManager.getConnection(url);
              catch (Exception E){
                   E.printStackTrace(System.out);
              return mySqlCon;
         * Metodi saa sy�tteen��n SQL komennon, jonka se suorittaa sek� palauttaa komennon tulokset.
         * @param command
         * @return ResultSet
         public static ResultSet querySQL(String command,String error, Connection con){
              ResultSet rs = null;
              try{
                   Statement stmt = con.createStatement();
                   rs = stmt.executeQuery(command);
              catch(Exception E){
                   E.printStackTrace(System.out);
              return rs;
    the jsp page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page isErrorPage="false" %>
    <%@ page import="java.sql.*" %>
    <%@page import="ot3.User"%>
    <%@page import="ot3.SqlInjektor"%>
    <%@page import="Javax.servlet.jsp.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>vastaanotto</title>
    </head>
    <body>
    <%!      String id;
         String password;
         String error = new String("Error!\n");
         User user;
    %>
    <%      user = new User();
         session.putValue("currentUser",user);
         id = request.getParameter("authName");
    password = request.getParameter("Password");
         Connection conn=null;
         ResultSet rs=null;
         conn = SqlInjektor.createConnection(error);
         if(conn!=null){
              out.println("conn ok!");
              rs = SqlInjektor.querySQL("SELECT * FROM user WHERE id='" + id +"' AND password='" + password+"' COLLATE latin1_bin;",error,conn);}
         try {
              if (rs!= null && rs.next()){
                   user.setID(rs.getInt("id"));
                   user.setName(rs.getString("name"));
                   user.setPassword(rs.getString("password"));
                   user.setClearance(rs.getInt("clearance"));
                   if(rs.getString("addedby")!=null)
                        user.setAdder(rs.getInt("addedby"));
                   if(rs.getString("lastmodifier")!=null)
                        user.setModifier(rs.getInt("lastmodifier"));
                   rs.close();%>
                   ONNISTU!
              <%}
              else {
                   out.println(error);     
         } catch (SQLException e) {
              out.println(e.getMessage());
         }%>
    </body>
    </html>

  • PleaseHelp on jsp and Mysql connectivity and a lot of exception errors

    Hi,
    I am Trying to connect a JSP page with Mysql database. I am having a lot of probelms. After having a lot of problems in connecting the JSp with Mysql. Intilally it was giving me the exception error that " NO appropriate driver was found. After modifying the URl it was fine. Now It is giving the Following errors.
    servlet.ServletException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream ** BEGIN NESTED EXCEPTION ** java.io.IOException MESSAGE: Unexpected end of input stream
    In a window before loading the Explorer page it is giving the following error that The port 8081 is already in use and i should expand to other ports. Noraml JSP Files which used to work before are also not working .
    Internal Tomcat JWSDP is alos not working. If i try to start the server it says that port 8081 is already in USe . A java.net.connection exception is also occuring. The normal JSP files are also not working. What is Happening. I am also giving the code i have writted. PLease tellme why so many exception errors are occuring.
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8081/mis_project", "root", " ");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("Select study_semester FROM Semester");
    while(rs.next()) {
    %>
    <option value="<%= rs.getString("Study_Semester") %>">
    </option>
    <% }
    if(rs!=null) rs.close();
    if(stmt!=null) stmt.close();
    if(con!=null) con.close();
    I am trying to connect to Mysql and automatocally populate a field in a Form in later JSp pages i intend to record the data entered in these fields into other tables.

    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/myDB?user=username&password=mypass");
    Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
    String cat = "";
              try{
              cat = request.getParameter("category");
              }catch(NullPointerException npe){}
              ResultSet rs = stmt.executeQuery("SELECT id,fullname FROM users WHERE category LIKE '%motor%' AND subcategory like '%"+cat+"%'");
         %>
    This piece gets a category parameter from a form post and uses it to search for a specific category in a database table. I think maybe u need to download JConnector from mysql site and unzip it to the classes folder of your WEB-INF in Tomcat server...... i hope this helps a bit

  • Few question about Java and MySQL connection

    Hi!
    I have some problems with creating connection between Java and MySQL.
    I followed the restrictions in mysql-connector-java.jar' readme, I set the CLASSPATH :
    CLASSPATH=.;D:/mysql/mysql-connector-java.jar;
    I copied this jar file to the right place (descripted above), and I used the right steps to load it:
    Class.forName('com.mysql.jdbc.Driver"); and it throws a ClassNotFoundException
    Why? All the paths are correct, everything is on the right place.... I dont know why.
    When I installed the JBuilder8, and copied the jar file to JBuilder8/jdk4/jre/lib/ext it worked without any CLASSPATH in enviromental variables.
    If I want to run my program on machines where are not JBuilder, what should I do?
    Please help, if you can.
    Thanks,
    henpanta

    Yeah. So if I compiled my program with JBuilder to an .exe file, I cant run it on other machines, if the jar file isnt in the same place?
    If I tried your advice, java -classpath mymainclass I got the next message:
    main class not found. Believe me, its there. :(

  • A question about JDBC and MySQL

    hello dear friends,ask a question:
    if in MySQL database, i have defined a clumon as TEXT data type.
    when i use JDBC, i use which kind of java data type to hold TEXT,
    i mean which getXXX() method i should use.
    is it possible i just use getObject() and cast it to a binarystream??
    thanks in advanced.

    use this:
    declare it 1st
    String x ="";
    then u can now get the value of the field...
    x = getString("<fieldName>");is there length limitation?
    for example, i want store a String which is got from a JTextArea, i also treat it as String and insert into the column with TEXT datatype like
    insert table_name (text_column) values( string_1)
    this works in JSP, should work in JAVA too...
    hope i helped... ^_^

  • JSP and MySQL

    dear all,
    I am new to sql and database programming and am a bit confussed about the line:
    Connection Conn = DriverManager.getConnection("jdbc:mysql:dbname");
    the jdbc is the what is the dbname??? is it the address of the database on your hard drive??? how is it formated??? what is the file that you need to point to??? how dies this work
    Thanks T

    Hi
    the JDBC Url should have the following format
    jdbc:mysql://<hostname>:<port>/<database>
    If your MySQL Database is running at your local host
    and it is using the default port than you can use
    jdbc:mysql://127.0.0.1:3306/test
    jdbc -> Means you are trying to open a jdbc connection
    mysql -> MySQL Databse Driver
    (make sure that your MySQL jdbc driver is registered)
    to connect to the test database on your MySQL Server
    regards
    thsimon

  • Questions from a Rookie about JSP and JEE

    Hello friends. I've just started to learn JEE and JSP technologies. I have some experience with .Net and PHP; but just found time to learn JSP. I have developed a simple Web application by using those technologies. And I want to deploy those codes to the web. I have googled. But could not find an explanatory tutorial about this topic.
    My second Question is:
    I am using Netbeans 6 Beta 2 and I am connecting to a Database by using a function let's say something called connectDb() with SSH;. How can I bind a Data table with this function. (Netbeans have a buildin component for binding to a component to db but does not support SSH)
    Thanx in advance. I would appreciate any kind of help.

    Hello.
    Is there anybody in there?
    Just reply if you can help me.
    Is there anyone here?
    By Dink Floyd

  • Help for documentation about  jsp and tomcat

    Hello
    This is realy very urgent for me!!Does anuone can help me.
    There is my problem .I nead books (hypperlink) for jsp or tomcat.
    who made it why and how does it looks.I am writeing documenation for my project and i have to finish it very soon.I found some tutorials btu it is noy enough if you know for something better i would be vry gratefull.
    By

    Hi,
    I agree, the basic documentation at the jakarta site is good, but needs a little polishing/updating.
    Use google to do a search, and wade through loads of stuff before coming up with the answers, or this site is pretty good too!!!!!
    Unfortunately, all the answers are not always forthcoming until you know which questions to ask (or the relevant words to enter into a search engine).
    best
    kev

  • JSP and MySQL - Datetime

    Hi, I am pretty new using MySQL. I have doubt on the datetime field used in MySQL.
    Here is my issue. I have a datetime column, called CreatedDate.
    I store the strTodayDate in it.
    Date dtTodayDate = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String strTodayDate = sdf.format(dtTodayDate);
    But when I retrieve it and display on page, it gave me 2005-05-26 09:25:19.0 <--- extra dot & zero.
    Can someone please kindly advise me why?
    Thank you very much.

    When storing date time it does not realy store it in the same format you give it.
    and when you retrive the date time the my sql simply dont know in which format did you save it. So it will give it in a standerd format.
    When you store and retrive date/time value use java.sql.DateTime / Date / Time objects and always use methods like setDate and getDate. do not convert them to strings.
    I my applications I also used to store dates as long values (in millisecs) in column type BIGINT instead of actual date time column type. That way also you can overcome this problem since my sql will not treat the value as a date but as a long number.

  • JSP and MySQL timestamp

    hi all,
    we have a MySQL database containing a TAGLOG table and the following columns:
    TAGNUMBER, int
    TAGVALUE, float
    TAGTIMESTAMP, timestamp
    a Schneider Electric Factory Cast HMI Modicon PLC module keeps logging data from the PLC onto the TAGLOG table.
    we need to set-up a form to allow the user to select:
    start date: ____
    start time: ____
    end date: ___
    end time: ___
    so we can build a query, send to the database and when thre Result Set is received show on a table format.
    Any assistance in setting up a user friendly form to enter above dates and times will be appreciated.
    thanks in advance for any assistance.
    Trajano

    this is a problem i need to deal with soon, and am wondering the best way for it as well.
    the easiest (and quickest) would be a simple text box for each, where user types date and time as a string, with separators eg 13/03/1982 or 13:32
    Otherwise three drop-down lists, one for day, one for month & one for year. Similar for time.
    for me it's not worth creating or buying some fancy 'calendar' control, but i'm sure there are many available.

  • Jsp and mysql... best aproach

    hi all ! I need to do some checking of some data before submiting my form. So my idea is that depending on what you select in a list/ menu the values of another list changes. I know I could do this with javascript. The problem is that I want to make the values from the second list reflect data that is stored in a database.
    So how can I do this ?
    Any advice, recomendations, links are apreciated.

    Me, I would put an onChange event on the first select box that submits a form to retrieve the content of the second select box.
    There are ways to do it without a submit though:
    1) dynamic select box. It involves putting all possible values for the second select box into a huge javascript array and you use the first select box to index into this array.
    2) Ajax. With ajax you can fetch the data for the second select box in the background.
    3) hidden iframe. If you don't want to use ajax directly you could load a page in a hidden iframe that will mimic the ajax call.
    For all three options there are numerous articles on the web, just search for them.

Maybe you are looking for

  • Instrument doesn't work on yosemite

    I tried to use Instrument on my Yosemite. It gave me "this device desnt support this instrument" error.

  • Book marks in PDF

    Hi, I would like to convert a Word document into a PDF file.  But only chapter headings not their chapter numbers form this WORD document schould be converted in book marks in the PDF file. I use WORD 2002 and Adobe Acrobat 8. For example: chapter he

  • Sporadic problem: The report server has encountered a configuration error. Logon failed for the unattended execution account.

    I have 2 reports that have subscriptions.   I am sporadically getting this error.   If it was really a configuration problem then I think I should get the error every time.     Does any one have any suggestions of what to look for?    I have not foun

  • Client change in r/3

    Hi experts, We have BI dev server which is connected to r/3 quality having client 600 but now quality is refreshed and new client is 500. ryt now data is coming from 600 . please tell me what changes should be done so that now data comes frm 500 not

  • Problem in Static Stub Client

    Hello...!!! I am trying to learn web services using j2ee. when I try to build the static stub client, using 'asant build', build always failed. I've already built the service n can see its wsdl in ie. I have given all the process below after typing '