Newbie Question

M

Mike

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top