How can I using java bean to insert new record

Hi everybody,
I'd some problem when I insert a record using java bean. When insert a record, the resultset executeUpdate return 0 anc cannot add record to database. Would you please tell me what's wrong in my code?
java bean
package miniproj;
import java.sql.*;
public class Register{
private String sql;
private String username;
private String usertype;
private String password;
private String blocknum;
private int floornum;
private String owner;
private int rows;
private String s;
// set parameter to database
public int setMember(){
try{
//load database driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Get a connection to the database
Connection sqlConn = java.sql.DriverManager.getConnection("jdbc.odbc:WFBS");
// Get a statement from the connection
Statement sqlStmt = sqlConn.createStatement();
sql = "INSERT INTO USERS(user_name, password) VALEUS ('aaa', 'aaa')";
// sql = "INSERT INTO USERS(user_name, password) VALEUS (" + user_name + "," + password + ")" ;
rows = sqlStmt.executeUpdate(sql);
// sqlRst.close();
sqlStmt.close();
sqlConn.close();
catch(SQLException se){
catch(Exception e){
return rows;
// set user name method
public void setUsername(String name){
username = name;
// set passwrod method
public void setPassword(String pwd){
password = pwd;
// set block num mehtod
public void setBlockNum(String block){
blocknum = block;
// set floor num method
public void setFloorNum(int floor){
floornum = floor;
// set owner method
public void setOnwer(String own){
owner = own;
// get user name method
public String getUsername(){
return username;
// get password method
public String getPassword(){
return password;
jsp code
<%@ include file="Header.jsp" %>
<%@ page errorPage="Error.jsp" %>
<jsp:useBean id="register" class="miniproj.Register" />
<jsp:setProperty name="register" property="*" />
User name : <%=register.getUsername()%><br>
Password : <%=register.getPassword()%><br>
<%
int i = register.setMember();
out.println(i);
%>
Thanks a lot
Chris

Seems to me that executeUpdate() would throw an SQLException, which in turn would get caught by your empty catch. The SQL keyword VALUES is misspelled. Put a 'se.printStackTrace()' in your catch to confirm this.

Similar Messages

  • How can i use JAVA BEAN and JSP?

    well, i have developed all my web apps by using pure JSP only, i know this sucks, but i dont know how to start on using beans... what directory should i put them into... etc... what are the good programminmg practices/standards/techniques when incorporating beans in jsp???

    Standards are pretty loose, but generally, Beans hold a lot of the backend logic for your JSP. This can include data validation before entering into the database, database inserts, queries, data manipulation. The JSP should really only contain code that will retrieve the data from the bean and appropriately output it.
    As far as using them, you can use the <jsp:useBean> tag in your JSP. As long as the bean is stored somewhere that your classpath points to, you're all set. From then on, you can use it like any other object in your JSP.

  • How can we  use java variable in javascript code on JSP page?

    How can we use java variable in javascript code on JSP page?
    Pls help

    Think about it:
    JSP/Java is executed on the Server and produces HTML+JavaScript.
    Then that HTML+JavaScript is transfered to the client. The client now interpretes the HTML+JavaScript.
    Obviously there's no way to access a Java variable directly from JavaScript.
    What you can do, however, is write out some JavaScript that creates a JavaScript variable containing the value of your Java variable.

  • How & where to use Java script to create new button in object detail page

    Hi All,
    I want to create "New/Add button" in object detail page. If i am not wrong i need to use java script for that but could you please let me know how & where to use Java script to create new button in object detail page in CRMOD.
    Thanks in advance.
    Regards,
    Manish

    Any related object on the detail page should have an "Add" or "New" or both buttons by default - This is vanilla functionality and will do the required action.
    If you want to modify this behaviour and do something tricky you will potentially have to go for javascript. You should add the javascript on a custom web tab on that Object.
    Admin --> Application Customization --> Contact -->Contact Web Applet
    Now, add your javascript in the code area, after you select the type = HTML for this web applet, expose this web applet on the Contact detail layout and your javascript will be invoked whenever this page is loaded.
    Check this online document to see how javascript can be embedded in CRM on Demand http://helponmyproject.com/TTOCOD/
    Cheers!
    Royston

  • How can I use Aperture 3 on my new iMac with Maverick?

    How can I use Aperture 3 on my new iMac with Maverick?

    Do you own a copy of Aperture, perhaps bought for another Mac?
    If you have not bought Aperture, you need to buy it from the AppStore.
    But if you own Aperture and have it bought from the AppStore on another Mac, sign into theAppStore on your new iMac with the same AppleID you used to buy Aperure on your other Mac.  Then look at the "Purchased" tab of he AppStore. It show Aperture, with the "Install" button to the right. Simply press the "Install" button and download it to your new iMac.  Or if you have bought Aperture on a CD/DVD, run the installer from the CD/DVD on your new mac and immediately run software update to upgrade the Aperture 3. version to version that will run with Mavericks.
    Léonie

  • How can i use text expander with the new Mavericks,

    how can i use text expander with the new Mavericks,

    I regret upgrading to mavericks for the same reason
    ftamez wrote:
    how can i use text expander with the new Mavericks,
    Now I have been searching - and you have to buy an app and it will cost you $34.99 (what a rip off)

  • How can i use Java

    How can i use javabeans in forms?

    You need to Create your JavaBean.
    Then you need to run the "Oracle Forms PJC" Wizard which can be found at File | New .../Beans tab.
    This wizard generates the correct adapters to allow JavaBean properties/events to be propogated to / from the Forms environment.
    For more details, please search the Help system for PJC.
    -John

  • How can I use my ipod to a new computer..

    How can I use my ipod to work on a new computer? I am using windows xp. I am having problem with my old computer with my itunes in it and I want to transfer everything on my new computer.
    Thanks

    How to use your iPod to move your music to a new computer using iTunes7
    http://docs.info.apple.com/article.html?artnum=300173
    How to use your iPod to move your music to a new computer using iTunes6
    http://docs.info.apple.com/article.html?artnum=304304
    Copying from iPod to Computer threads...
    http://discussions.apple.com/thread.jspa?messageID=5044027&#5044027
    http://discussions.apple.com/thread.jspa?threadID=893334&tstart=0
    http://discussions.apple.com/thread.jspa?messageID=797432&#797432
    Also these useful internet articles...
    http://www.engadget.com/2004/11/02/how-to-get-music-off-your-ipod/
    http://playlistmag.com/secrets/2006/12/twowaystreet20/index.php
    http://playlistmag.com/help/2005/01/2waystreet/
    Patrick
    p.s. iPod: Frequently Asked Questions
    http://docs.info.apple.com/article.html?artnum=60920

  • How can i use my purchased game in new apple id

    I purchased some apps by my apple id ,but unfotunately i have some problem that why i changed  another apple id in my device .after that i cant synchronise & run...how can i use those purchased apps in my different id?????

    please help me?

  • I have an CS2 version of Photoshop on an old computer that got hit by lightening.  How can I use this version on my new computer?

    How can I use a CS2 version of photoshop on a new computer after my old computer got hit by lightening?

    CS2 version is only compatible with till Windows XP, If you trying to install on new Operating system, it might will give you errors.
    Also the activation server is not available for CS2 versions.
    You can refer to the help document:
    http://helpx.adobe.com/x-productkb/policy-pricing/creative-suite-2-activation-end-life.htm l

  • How can I use Java to do Seismic programming as Motif?

    One of my friend recently finished a seismic on-site data processing program using
    Motif on Solaries.He asked me if I can implement the same function to use Java language
    so that the program can run on different platforms such as Windows,Unix.
    Seismic data is usually enormous.And I don't have any experence in plotting seismic
    curves by using Java.
    Is there any seismic processing software programmed with Java available?
    I will appriciate any help.
    Thank you

    I think the point is not the word seismic than 'how to plot curves in Java.'.
    You can find many resources about plotting curves you want in Java2D.
    Refer to these URL:
    Java2D http://java.sun.com/products/java-media/2D/index.html
    Java2D Tutorial http://java.sun.com/docs/books/tutorial/2d/index.html

  • How can get & use java true type fonts in my applets

    Hi
    I could get the System fonts in my Applet by making use of Toolkit.getFontList()
    I have used getGraphicsEnvironment to get fonts but my browser doesn't support it.I get ClassNotFoundException.
    How can I get & make use True Type Fonts in my Java Applet.
    any body knows reply immediate pls
    Siva

    similar problem:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=164516
    sorry, thats all i know.
    tobias

  • How can I use java with DMI(Desktop Management Interface)? Help please..

    I want to use Java to develop DMI. Please help...Thanks.

    You are not getting replies because your question may need a course to answer. Just like, hey, can someone tell me how to write an email application? Or,
    Can someone show me how to build a house?
    Start writing your application, when you get stucked, post your questions.
    Or, at least be more specific. Like, elaborate DMI and things like that.
    Do a search on DMI, you may find what you need.

  • How can i use Java proxies?

    Hi,
    Q1. Where all can  java proxies be used?  Is it only in scenarios where a java appication(like jsp) is involved?
    I have a IDOC-XI-SFTP scenario.
    I have a java program that creates the SSH session and transfers files. I can use this as a Java Mapping and do the SFTP , but can i do it in java proxies? if yes then how can i create the java proxy as the receiver. Note:  i dont have a java application in the sceanrio.
    pls tell me if its not clear, i can clarify.

    Hi,
    In addition to what michal said i would like to share some good references with you.
    java proxies
    Java Proxies and SAP XI: The Inside
    Story u2013 Part I
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a068cf2f-0401-0010-2aa9-f5ae4b2096f9
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f272165e-0401-0010-b4a1-e7eb8903501d
    /people/yugapreetha.t/blog/2007/12/03/pre-requisites-for-client-java-proxies
    Asynchronous Inbound Java Proxy.
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1929. [original link is broken] [original link is broken] [original link is broken]
    advanced search
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=java+proxy&adv=false&sortby=cm_rnd_rankvalue#
    Concept of proxy generation
    /people/srinivas.gv/blog/2005/09/27/concept-of-proxy-generation
    An Illustration of Java Server Proxy
    /people/rashmi.ramalingam2/blog/2005/06/25/an-illustration-of-java-server-proxy
    rgds
    joel

  • Hi, On Maverick (Mac OS X 10,9) how can I use Java?

    Hi, Could somebody suggest me the way, how, which update of Java can be used on Maverick?
    Thanks in advance
    juliafromhun

    I use Oracle's Java, Java 7 build 45. You can download it from -> http://www.java.com/en/download/faq/java_mac.xml.
    Good luck,
    Clinton

Maybe you are looking for

  • How do I create a link to the middle of a page with Inherit Zoom?

    I keep going around and around on this.  I am using Adobe Acrobat XI Pro and I'm trying to create an internal link in the PDF to go to the middle of the page somewhere else in the same document.  I don't want to change the user's zoom level. I can cr

  • How to customize SORT event in the View Form ?

    I'm using Jdevelper 9.0.3 with BC4J+UIXML, and I need customize the View Object Query, including "bind variables" as: SELECT A.COD_CLIENTE, A.NUM_TESTE, A.NOM_TESTE FROM TESTE A WHERE A.COD_CLIENTE = :1 I create the java class for prepare assign valu

  • Intensive GC times when collecting the old generation with parallelOldGC

    h1. We are experiencing some very strange GC times h2. The hardware/OS OS: Microsoft Windows XP Service Pack 2 (build 3790) (64bit) CPU: Intel(R) Xeon(R) CPU 8X E5530 @ 2.40GHz (Hyper Threading Enabled) RAM: 4078 Mb total h2. The application JBoss 4.

  • Backup setting for ECC 6.0 on DB2 and Windows

    Hi Expert Please send step for Online and offlice disk backup for ECC 6.0 on DB2

  • Installing of midlets onto Nokia 7210

    I've tried to download some midlets from http://midlet.org/ & then install to my N7210 via IR. This however doesn't seems to work. However, when I make the same attempt using the Nokia PC Suite, it works. Is there a specific protocol used by the Noki