Project on Online Shopping Cart in JSP, SQL.


Rahul++

SuperUser
Adept
Aug 27, 2007
3,142
175
152
28
Pune
www.wrapcode.com
Hello people.

I've decided to work on project with title "Online Shopping Cart" for this semester. The project will be done using JSP and database will be SQL/MS Access.

Since I'm newbie in JSP and SQL. I don't know from where should I start.

Overall, the project should have - User Registration, Payout Receipt, Admin Panel, Item modification (Add, remove, update), Search Feature, Multiple Payment options. We haven't learnt JSP, SQL or any similar language yet but we've do work on project as it is a part of syllabus.

Now the big part. I'm looking through some online JSP, SQL tutorials. I'm getting general idea about what it is. But I don't know from where should I start. I know java programming very well which will be used there ofcourse.

I can't just think, from where should I start. Can any experts help me? Please reconsider that I'm not asking for any ready made project or code. I'm just asking help about it.

Thanks,
Rahul.
 

Compiler

Active Member
Adept
Feb 4, 2010
517
14
31
35
Just a suggestion Better you start using a IDE like eclipse or netbean to speed up the development.

good way to do this is register @ sun forum and start posting your queries there.
 

Rahul++

SuperUser
Adept
Aug 27, 2007
3,142
175
152
28
Pune
www.wrapcode.com
We've Core Java in this semester's syllabus. Our Project guide suggested us to develop the project using Java Server Pages so that It'll be easy to understand for Project Team. If it was only me, I would have chosen PHP for developing this project but the case is, I'm having two classmates are my project partner (typical dumby engineer students :mad: :mad:) who doesn't want to develop in other than JSP. They're just following Project Guide's suggestion instead of trying something interesting. :(

I really don't know from where to start :(
 

Rahul++

SuperUser
Adept
Aug 27, 2007
3,142
175
152
28
Pune
www.wrapcode.com
^ LOL.. I've been through lots of JSP Tutorials and all.. Even I've created some pages like Login page, Registration Page (Only accepting and storing values in string, database work is yet to be done).. But I'm unable to establish connection with MySQL database using JSP. I'm using following code -

Code:
<%@ page import="java.sql.*" %> 

<%@ page import="java.io.*" %> 

<html> 

<head> 

<title>Connection with mysql database</title> 

</head> 

<body>

<h1>Connection status </h1>

<% 

try {

String connectionURL = "jdbc:mysql://localhost:3306/rahul";  //[B]rahul[/B] is database name.

Connection connection = null; 

Class.forName("com.mysql.jdbc.Driver").newInstance(); 

connection = DriverManager.getConnection(connectionURL,"root","root");

if(!connection.isClosed())

out.println("Successfully connected to " + "MySQL server using TCP/IP...");

connection.close();

}

catch(Exception ex){

out.println("Unable to connect to database.");

}

%>

</font>

</body> 

</html>
 

Compiler

Active Member
Adept
Feb 4, 2010
517
14
31
35
Can u use oracle XE as a database.

I can help you with the code if you use XE as a database.Its free but yet powerful database.

--- Updated Post - Automerged ---

Rahulrulez said:
^ LOL.. I've been through lots of JSP Tutorials and all.. Even I've created some pages like Login page, Registration Page (Only accepting and storing values in string, database work is yet to be done).. But I'm unable to establish connection with MySQL database using JSP. I'm using following code -

Code:
<%@ page import="java.sql.*" %> 
<%@ page import="java.io.*" %> 
<html> 
<head> 
<title>Connection with mysql database</title> 
</head> 
<body>
<h1>Connection status </h1>
<% 
try {

String connectionURL = "jdbc:mysql://localhost:3306/rahul";  //[B]rahul[/B] is database name.

Connection connection = null; 
Class.forName("com.mysql.jdbc.Driver").newInstance(); 
connection = DriverManager.getConnection(connectionURL,"root","root");

if(!connection.isClosed())
out.println("Successfully connected to " + "MySQL server using TCP/IP...");
connection.close();
}
catch(Exception ex){
out.println("Unable to connect to database.");
}
%>
</font>
</body> 
</html>
(Assuming you are using windows)check if you can telnet to port 3306.
This can be done by opening command prompt and typing following.

telnet localhost 3306
if it says
"Connecting To localhost...Could not open connection to the host, on port 3306: Co
nnect failed"

Then check if mysql is running on port 3306 or not.
However i have ready made code for what you are trying to achieve but its written on ORACLE XE .
 

Rahul++

SuperUser
Adept
Aug 27, 2007
3,142
175
152
28
Pune
www.wrapcode.com
I just had set up environment for Apache Tomcat, MySQL. Can you please guide me, how to install JDBC drivers? I've never done that. Sorry for my noobness. :(
 

anupamsinha

Active Member
Disciple
May 28, 2005
126
0
27
The code posted above is from JSP. This is not the best way to implement connection to a DB.
Read about MVC. MVC is Model View Controller.
Creating DB connections is a heavy weight process. Choose a connection pooling algorithm. If you are using Tomcat, it ships with DBCP, read on that and connection pooling should not be a problem.

But foremost is the design.

Don't start with coding right away. Think what all entities would be required. For example entities are Customer, ShoppingCart, Address etc. How would these interact with each other.

Design a database schema. Design class diagrams. Get it reviewed by someone. Once you have all this ready developing an application around it should not be much of a problem.

In case you have any issues, PM me, better just post the query here.
 

shank21101985

Active Member
Disciple
Feb 10, 2007
121
1
29
get urself "Head First JSP and Servlets"

it wud hlep u kick start ur development... wud tell u about MVC etc...

that shud take care of the coding part...

now if u have never designed a database before, thats what u need to work on... Seriously... a bad database design would keep bothering u at later stages of development... so do give considerable thought to the database design... if u dont know what database designing means, its time to head to GOOGLE ;)

--- Updated Post - Automerged ---

on second note... if that code was just to show that u can connect to database from jsp then its fine... but if u ever find a guy using it in his project... KICK HIM !!

--- Updated Post - Automerged ---

u dont need to install JDBC drivers.. they are java classes that u need to include in ur classpath... start using eclipse if u do want to finish the project in this semester :)

lol
 

Compiler

Active Member
Adept
Feb 4, 2010
517
14
31
35
Rahulrulez said:
I just had set up environment for Apache Tomcat, MySQL. Can you please guide me, how to install JDBC drivers? I've never done that. Sorry for my noobness. :(
Following tut will connect to the xe database but according to me you havn't put ojdbc jar files of MySQL to tomcat lib folder like what i did in this tut.
Write a small JSP program to fetch Data from Database (ORACLE XE).

Now We need to connect our database to application server.
For this we need to copy jdbc jar files to apache tomcat library.

cp /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/jdbc/lib/ojdbc14.jar /install/apache-tomcat-5.5.29/webapps/jsp-examples/WEB-INF/lib/
cp /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/jdbc/lib/ojdbc14_g.jar /install/apache-tomcat-5.5.29/webapps/jsp-examples/WEB-INF/lib/

Restart tomcat service.

This is a sample application to run a webpage which is integrated to database.

Code:
<%@ page import="java.lang.*" language="java"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>

<%
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "lightweight", "oracle");
Statement stmt=conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from LIGHT_CRED");
        while (rset.next())
{
              out.println (rset.getString(1));
              out.println(rset.getString(3));
}
stmt.close();
conn.close();
%>