Project on Online Shopping Cart in JSP, SQL.

Discussion in 'Programming' started by Rahul++, Aug 11, 2010.

  1. Rahul++

    Rahul++ SuperUser
    Adept

    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.
     
  2. Compiler

    Compiler Active Member
    Adept

    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.
     
  3. Gaurish

    Gaurish Well-Known Member
    ex-Mod

    Any reason for choosing using JSP over any over others?
     
  4. OP
    OP
    Rahul++

    Rahul++ SuperUser
    Adept

    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 :(
     
  5. Gaurish

    Gaurish Well-Known Member
    ex-Mod

    This might help: link :p

    on serious note,Try Head First Servlets And JSP - Its quite well written book, with everything presented in systematic manner, step by step. Quite useful if you are jsp beginner
     
  6. krishnandu

    krishnandu Well-Known Member
    Veteran

    Wow..!! That link is nice..!! :lol:

    A gr8 answer for them who can't google it out..!!
     
  7. OP
    OP
    Rahul++

    Rahul++ SuperUser
    Adept

    ^ 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> 
    
    
     
  8. krishnandu

    krishnandu Well-Known Member
    Veteran

    I just started learning J2EE. :) It's only been 2 weeks.

    Anyway sorry for posting non-related posts.
     
  9. Compiler

    Compiler Active Member
    Adept

    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 ---

    (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 .
     
  10. OP
    OP
    Rahul++

    Rahul++ SuperUser
    Adept

    ^ I successfully connected to localhost using port 3306.
     
  11. ultra vires

    ultra vires Active Member
    Adept

    You have copied the connection code from somewhere but didn't put the driver class in your JDK.

    If you are not able to connect after that PM me.

    Edit:

    Download JDBC connector from here : http://www.mysql.com/products/connector/
     
  12. OP
    OP
    Rahul++

    Rahul++ SuperUser
    Adept

    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. :(
     
  13. anupamsinha

    anupamsinha Active Member
    Disciple

    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.
     
  14. shank21101985

    shank21101985 Active Member
    Disciple

    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
     
  15. Compiler

    Compiler Active Member
    Adept

    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();
    %>
     

Share This Page