Aha, well you know better than me :) ..
Thanks for your consideration.. i will talk to my supervisor about it :) ..
Aha, well you know better than me :) ..
Thanks for your consideration.. i will talk to my supervisor about it :) ..
well jwenting im still in a level they dont teach us advanced things :) ..
Thanks :)
Thanks masijade :) ...
hehe no i dont want :P .. but this what they taught us in college !! ... basic things ..
however the most important thing is that the code doesnt fully change ... we have 4 weeks to finish the project :P ..
thanks again :)
this is the code ... it checks whether the id exist or no !! .. when the person insert ..
<%@ page language="java" import="java.sql.*" errorPage="" %>
<%!
String sqlStat;
Connection conn;
Statement stmt;
int prodno, price;
String prodname, ptype;
%>
<%
try {
prodno = Integer.parseInt(request.getParameter("prodno"));
prodname = request.getParameter("prodname");
ptype = request.getParameter("ptype");
price = Integer.parseInt(request.getParameter("price"));
sqlStat = "INSERT INTO itemTBL (PRODNO, PRODNAME, PTYPE, PRICE) VALUES ";
sqlStat = sqlStat + "(" + prodno + ",";
sqlStat = sqlStat + "'" + prodname + "',";
sqlStat = sqlStat + "'" + ptype + "',";
sqlStat = sqlStat + "" + price + ")";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:prodDSN","","");
stmt = conn.createStatement();
stmt.executeUpdate(sqlStat);
out.print("Product ID already exist");
%>
<br>
Click
<a href="selectall.jsp" >view all </a>
to bla bla
<%
conn.close();
} catch (Exception e) {
out.println("Error : " + e.getMessage() );
}
%>
this how the way ..
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT
then put ur files u want .. but if u want to put it in folder u need to put the web-inf inside this folder ,, u will find this web-inf in the root folder just copy and paste it on the folder ..
when u will use tomcat.. there is 2 ways .. if u just put ur files in ROOT then u just write
http://localhost:8080(u have to check ur host num maybe its 8081)/(write the html )
eg. http://localhost:8080/dbinsert.html
the 2nd way if its in a folder and u named example the folder "me" the it will be like this
http://localhost:8080/me/dbinsert.html
:)
Hi all ..
this jsp code when we use database access, to get the information by entering the price , my problem is that now iam using oracle as database and i dont know what are the changes that can be made here only ofcorse the path of database this i have , but string will it change because in oracle its varchar ? .. !! .. plz help.. its my first time to do this ..
Thanks :)
<html>
<body>
<%@ page import="java.sql.*" %>
<%
Connection con = null;
Statement st;
ResultSet rs;
String sql = "";
int price;
price= Integer.parseInt(request.getParameter("price"));
sql = "SELECT * FROM itemTBL where price = "+ price;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:prodDSN");
st = con.createStatement();
rs = st.executeQuery(sql);
%>
<table border=2>
<%
while(rs.next())
{
%> <tr>
<td><%=rs.getString("prodno")%></td>
<td><%=rs.getString("prodname")%></td>
<td><%=rs.getString("price")%></td>
<td><%=rs.getString("ptype")%></td>
</tr>
<% } %>
</table>
<%
rs.close();
con.close();
}
catch(Exception ex)
{
out.print(ex.getMessage());
}
%>
</body>
</html>