Presentation is loading. Please wait.

Presentation is loading. Please wait.

E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities.

Similar presentations


Presentation on theme: "E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities."— Presentation transcript:

1 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 1 Accessing Databases Ver: 1.0 E-Commerce Basic Applications Accessing Internet Databases

2 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 2 Accessing Databases How do APIs Work Imagine APIs (Application Interface) as a standardised set of functions that allow programs to access databases and execute SQL statements on that database There are APIs for PHP, PERL, Java... To work with databases e.g. MySQL To connect you need to execute your commands as a specific user which you need to set up first (see previous modules)

3 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 3 Accessing Databases APIs Discussed PHP PERL Java Server Pages (Java Servlets)

4 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 4 Accessing Databases PHP Web Server Database MySQL_Func.php Http request 1. User Page Connection_data.php 2. Call function 3. Receive Connection data 4. Request Data Receive Result Array 5.

5 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 5 Accessing Databases Database Connection PHP include("connection_data.php"); include("mysql_func.php"); $lk1=myconnect(); $db1="victory";

6 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 6 Accessing Databases Sample Query PHP $loginname = ”Messnarz”; $sql = SELECT customers.surname, products.productname, products.price FROM products,sales,customers WHERE products.prod_id = sales.prod_id AND sales.cus_id = customers.cus_id AND customers.surname LIKE ‘.“$loginname“.‘ “; if (!($result1=send_sql($db1,$query1))) { sprintf("internal error %d:%s\n", mysql_errno(), mysql_error()); return 0; } Runs Query on the database

7 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 7 Accessing Databases PERL Web Server Database MySQL Socket Http request 1. User Page use Net::SMTP; 2. Create Comm Object 3. Use Connection Modules 4. Request Data Receive Result Record Set 5.

8 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 8 Accessing Databases Database Connection PERL my $mysql = Net::MySQL->new( hostname => 'localhost', # Default use UNIX socket database => ‚dbname', user => ‚userid', password => ‚mypassword' ); Creating a var to access DB through a communication socket

9 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 9 Accessing Databases Sample Query PERL $mysql->query(qq{ SELECT customers.surname, products.productname, products.price FROM products,sales,customers WHERE products.prod_id = sales.prod_id AND sales.cus_id = customers.cus_id AND customers.surname = (‘Messnarz‘) }); my $record_set = $mysql->create_record_iterator; Runs Query on the database

10 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 10 Accessing Databases JSP + Tomcat (SUN) TomCat Server Database Java Servlet Http request 1. JSP Page Java Network Library 2. Converted To Servlet 3. Use Connection Modules 4. Request Data Receive Result Record Set 5.

11 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 11 Accessing Databases Database Connection JSP // creating db object try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); } catch (ClassNotFoundException e) { out.println(" ***Can't load JDBC!*** "); out.println(" ***Exception=" + e.toString() + "*** "); return; } // Connecting Connection myConn; try { Connection myConn = DriverManager.getConnection ("jdbc:mysql:///victory?user=iscn&password=test"); } catch (Exception e) {...

12 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 12 Accessing Databases Sample Query JSP // Step 3 Statement stmt = myConn.createStatement(); // Step 4 ResultSet myResultSet = stmt.executeQuery(" SELECT customers.surname, products.productname, products.price FROM products,sales,customers WHERE products.prod_id = sales.prod_id AND sales.cus_id = customers.cus_id AND customers.surname LIKE ´Messnarz´ "); Runs Query on the database

13 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 13 Accessing Databases Comparison PHP and JSP have a quick performance, PERL is slower JSP needs extensive Java knowledge (some semesters to study) Thus the course bases on PHP examples Be aware that although the principles are the same, the scripting languages look quite different.

14 E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities under the Leonardo da Vinci Programme 14 Accessing Databases References PHP for Beginners, Wrox Press, 1998 Professional PHP Programming, Wrox Press, 2000 Professional PHP4 XML, Wrox Press, 2002 JSP Online Tutorial : http://www.apl.jhu.edu/~hall/java/Servlet- Tutorial/http://www.apl.jhu.edu/~hall/java/Servlet- Tutorial/ PHP Conference Materials Site http://conf.php.net/http://conf.php.net/ Online PHP Manual http://www.zend.com/manual/http://www.zend.com/manual/


Download ppt "E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP-136012) is carried out with the financial support of the Commssion of the European Communities."

Similar presentations


Ads by Google