Newbie Question

Discussion in 'Java' started by Mike, Sep 14, 2004.

  1. Mike

    Mike Guest

    I am new to Java. I have been trying some simple JSP connections to a
    MS-SQL table. I wrote one that reads from a test database and table
    that I set up and works. I am now trying to write a simple one to use
    a form to fill in information and have this post to the table. This
    one I can't get to work and I don't know what I am doing wrong. I am
    just learning..
    Thanks in advance

    Here is my jsp:

    <%@ page import = "java.sql.*" %>
    <HTML>
    <HEAD>
    <%String Name;
    String Email;%>
    <TITLE> A JSP file for testing MSSQL database update</TITLE></HEAD>
    <BODY>
    <jsp:useBean id='clock' scope='page' class='dates.JspCalendar'
    type="dates.JspCalendar" />
    <form action="" method=POST>
    Your Name <input type="text" name="Name"><BR>  
    Your Email <input type="text" name="Email"><BR>  
    <input type="hidden" name="Posted" value="1">
    <input type="submit" value="Sign Up">
    </form>
    <%
    Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
    Connection con=java.sql.DriverManager.getConnection
    ("jdbc:microsoft:sqlserver://XXX:1433;User=XXX;Password=XXX");
    String sql;
    sql = "INSERT INTO XXX.dbo.MyUsers(Name, email) VALUES (?,?)";
    PreparedStatement ps = con.prepareStatement(sql,Name,Email);
    ps.executeUpdate();
    %>
    </BODY>
    </HTML>
    Mike, Sep 14, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry C.
    Replies:
    8
    Views:
    223
    Uri Guttman
    Nov 23, 2003
  2. Kruno Saho
    Replies:
    0
    Views:
    134
    Kruno Saho
    Apr 7, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    116
    Dave Angel
    Apr 7, 2013
  4. rusi
    Replies:
    0
    Views:
    106
  5. Miki Tebeka
    Replies:
    0
    Views:
    81
    Miki Tebeka
    Apr 7, 2013
Loading...

Share This Page