•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 397,794 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,359 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 2224 | Replies: 4
![]() |
•
•
Join Date: Sep 2006
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi I have a difficulty in insertion data. I wrote my html code (a form in it) and jsp code to get the form data and insert it to database. I don't get any error message but it doesn't insert data to database. My code is below. Where am I wrong?
---kisisel.html---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
//onSubmit olayýný yönlendirme fonksiyonu
function onayla() {
return confirm('Bu sipariþi vermek istediðinizden emin misiniz?');
}
//-->
</script>
</head>
<body bgcolor="#F7F5D5" link="#009900">
<p> </p>
<table width="96%" border="1" bordercolor="#003333" bgcolor="#CCFF99">
<tr>
<td align="center"><a href="kisisel.html"><strong><font size="+1">Kisisel
Bilgiler</font></strong></a></td>
<td align="center"><a href="egitim.html"><font size="+1"><strong>Egitim Bilgileri</strong></font></a></td>
<td align="center"><a href="beceri.html"><strong><font size="+1">Beceriler</font></strong></a></td>
<td align="center"><a href="ekbilgi.html"><font size="+1"><strong>Ek Bilgiler</strong></font></a></td>
</tr>
</table>
<p> </p><fieldset>
<p>
<legend><strong><font color="#663366" size="5">
<input name="imageField" type="image" src="../../../../../Documents%20and%20Settings/Nurhan/Belgelerim/nur/L3.gif" width="32" height="32" border="0">
Kisisel Bilgiler </font></strong></legend>
</p>
<form name="form1" method="post" action="test.jsp" >
<p><font color="#9900FF"><strong>Ad* : </strong></font>
<input type="text" name="ad">
<font color="#9900FF"><strong>Soyad*:</strong></font>
<input type="text" name="soyad">
</p>
<p><strong><font color="#9900FF">Dogum Tarihi*</font></strong>:
<input type="text" name="dogum">
</p>
<p><strong><font color="#9900FF">Cinsiyet* :
<label> </label>
</font>
<label></label>
</strong>
<label>
<input type="radio" name="cins" value="Bayan">
Bayan</label>
<label>
<input type="radio" name="cins" value="Erkek">
Erkek</label>
<br>
<label> </label>
<br>
<font color="#9900FF"><strong>Medeni Durum* :</strong></font>
<label> </label>
<select name="medeni_hal">
<option value="Evli">Evli</option>
<option value="Bekar">Bekar</option>
</select>
<input type="submit" name="Submit2" value="Kaydet" onSubmit="return onayla()" >
</p>
</form>
<p> </p>
</fieldset>
</body>
</html>
------------and here is test.jsp-----------
<html>
<head>
<%@ page
import = "java.io.*"
import = "java.lang.*"
import = "java.sql.*"
%>
<title>
JSP Example 2
</title>
</head>
<body>
<h1>JSP Example 3</h1>
<%
String ad=request.getParameter("ad");
String soyad=request.getParameter("soyad");
String dogum_tarih=request.getParameter("dogum");
String cinsiyet=request.getParameter("cins");
String medeni=request.getParameter("medeni_hal");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "C:/Program Files/Tomcat 5.0/webapps/jsp-examples/vt1.mdb" ;
String database = "jdbc:odbc
river={Microsoft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
Connection conn = DriverManager.getConnection( database ,"","");
Statement st=conn.createStatement();
st.executeUpdate("INSERT INTO veriler VALUES ('"+ad+"','"+soyad+"','"+dogum_tarih+"','"+cinsiyet+"','"+medeni+"'");
// st.executeUpdate("INSERT INTO iletisim VALUES ('"+adres+"','"+semt+"','"+sehir+"','"+ulke+"','"+evtel+"','"+ceptel+"','"+email+"'");
conn.close();
}
catch (Exception e) {
/* System.err.println("Got an exception! ");
System.err.println(e.getMessage()); */
}
%>
</body>
</html>
---kisisel.html---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
//onSubmit olayýný yönlendirme fonksiyonu
function onayla() {
return confirm('Bu sipariþi vermek istediðinizden emin misiniz?');
}
//-->
</script>
</head>
<body bgcolor="#F7F5D5" link="#009900">
<p> </p>
<table width="96%" border="1" bordercolor="#003333" bgcolor="#CCFF99">
<tr>
<td align="center"><a href="kisisel.html"><strong><font size="+1">Kisisel
Bilgiler</font></strong></a></td>
<td align="center"><a href="egitim.html"><font size="+1"><strong>Egitim Bilgileri</strong></font></a></td>
<td align="center"><a href="beceri.html"><strong><font size="+1">Beceriler</font></strong></a></td>
<td align="center"><a href="ekbilgi.html"><font size="+1"><strong>Ek Bilgiler</strong></font></a></td>
</tr>
</table>
<p> </p><fieldset>
<p>
<legend><strong><font color="#663366" size="5">
<input name="imageField" type="image" src="../../../../../Documents%20and%20Settings/Nurhan/Belgelerim/nur/L3.gif" width="32" height="32" border="0">
Kisisel Bilgiler </font></strong></legend>
</p>
<form name="form1" method="post" action="test.jsp" >
<p><font color="#9900FF"><strong>Ad* : </strong></font>
<input type="text" name="ad">
<font color="#9900FF"><strong>Soyad*:</strong></font>
<input type="text" name="soyad">
</p>
<p><strong><font color="#9900FF">Dogum Tarihi*</font></strong>:
<input type="text" name="dogum">
</p>
<p><strong><font color="#9900FF">Cinsiyet* :
<label> </label>
</font>
<label></label>
</strong>
<label>
<input type="radio" name="cins" value="Bayan">
Bayan</label>
<label>
<input type="radio" name="cins" value="Erkek">
Erkek</label>
<br>
<label> </label>
<br>
<font color="#9900FF"><strong>Medeni Durum* :</strong></font>
<label> </label>
<select name="medeni_hal">
<option value="Evli">Evli</option>
<option value="Bekar">Bekar</option>
</select>
<input type="submit" name="Submit2" value="Kaydet" onSubmit="return onayla()" >
</p>
</form>
<p> </p>
</fieldset>
</body>
</html>
------------and here is test.jsp-----------
<html>
<head>
<%@ page
import = "java.io.*"
import = "java.lang.*"
import = "java.sql.*"
%>
<title>
JSP Example 2
</title>
</head>
<body>
<h1>JSP Example 3</h1>
<%
String ad=request.getParameter("ad");
String soyad=request.getParameter("soyad");
String dogum_tarih=request.getParameter("dogum");
String cinsiyet=request.getParameter("cins");
String medeni=request.getParameter("medeni_hal");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "C:/Program Files/Tomcat 5.0/webapps/jsp-examples/vt1.mdb" ;
String database = "jdbc:odbc
river={Microsoft Access Driver (*.mdb)};DBQ="; database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
Connection conn = DriverManager.getConnection( database ,"","");
Statement st=conn.createStatement();
st.executeUpdate("INSERT INTO veriler VALUES ('"+ad+"','"+soyad+"','"+dogum_tarih+"','"+cinsiyet+"','"+medeni+"'");
// st.executeUpdate("INSERT INTO iletisim VALUES ('"+adres+"','"+semt+"','"+sehir+"','"+ulke+"','"+evtel+"','"+ceptel+"','"+email+"'");
conn.close();
}
catch (Exception e) {
/* System.err.println("Got an exception! ");
System.err.println(e.getMessage()); */
}
%>
</body>
</html>
Well, you might not be getting an error message, because you have commented out the contents of your catch block, effectively ignoring any errors. Remove the comment symbols in the catch block and try it again in order to check whether or not you actually get any error messages.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Did you remove the comments in the catch block or only the comment symbols (i.e. /* and */). If you removed the comments all together, then of course you are still not seeing any errors as the catch block is still empty. Make sure the catch block is actuall doing something. Your catch block should be as follows:
Make sure that it is that way, and try again. Then tell us what error you get.
And, trust me, if your path were wrong you would be getting errors. Usually ClassNotFoundException errors.
catch (Exception e) {
System.err.println("Insertion Error: " + e.getMessage());
e.printStackTrace();
}Make sure that it is that way, and try again. Then tell us what error you get.
And, trust me, if your path were wrong you would be getting errors. Usually ClassNotFoundException errors.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
access avatar backup breach broadband code combo crime daniweb data data protection data transfer database design drive dropdownlist forensics government hacker hard hardware hitachi ibm internet linux medicine module net news normalization reuse security server sql storage survey terabyte web wikipedia
- How to insert data into database? (JSP)
- how to insert data into the database in vb.net using textfields. (VB.NET)
- insert and update data in two different database (JSP)
- Problem with update data to database (JSP)
- Populate data from database into JList (Java)
Other Threads in the JSP Forum
- Previous Thread: Passing variable value from javascript to jsp page at run time
- Next Thread: Type mismatch: cannot convert from int to ResultSet



Linear Mode