IBM BlueMIX pradmenys (aplikacijų talpinimas) (java-mysql; php-mysql atvejai) Autorius: Jonas Skendelis © 2014, Visos teisės saugomos Pastaba: prezentacija.

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

19 augustus 2003augustus 2003 JSP-2. BICT 2JDBC BICT 3Install MySQL Download MySQL daemon – Free – Windows version… Start Daemon – Mysqld-nt.exe Download.
Basic JDBC Celsina Bignoli What is JDBC Industry standard for database- connectivity between the Java language and a wide range of.
Objectives Connect to MySQL from PHP
Programming for the Web Assignment 1 Help Mark Johnson.
Murali Mani Web Interface. Murali Mani Options PHP with mySQL JSP/Servlets with JDBC on mySQL/Oracle Others …
TUTORIAL (1) Software installation Written by: Eng. Ahmed Mohamed Abdel Ghafar, Edited by Eng. Muhammed Hammad, Eng. Hamdy Soltan & Eng. Osama Talaat.
UFCE4Y UFCE4Y-20-3 Components and Services Julia Dawson.
PHP on a Fast Track a quick introduction to PHP programming by Jarek Francik.
Lab: JDBC 1 Computer Engineering Lab III v Objective –to give some background on JDBC to help with the lab exercises , Semester 1,
INTERNET APPLICATION DEVELOPMENT For More visit:
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
FUNCTIONS AND STORED PROCEDURES & FUNCTIONS AND PROTECTING A DB AND PHP (Chapters 9, 15, 18)
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
JAVA Database Access. JDBC The Java Database Connectivity (JDBC) API is the industry standard for database- independent connectivity between the Java.
Polling System Part 1 Creating PHP & MySQL Files CIS 254.
Lecture 10 – MYSQL and PHP (Part 2)
Servlets Database Access. Agenda:  Setup Java Environment  Install Database  Install Database Drivers  Create Table and add records  Accessing a.
CS 160: Software Engineering October 1 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
MySQL Database Connection
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Accessing Database using JDBC. JDBC Objectives Gain basic knowledge of Java JDBC Become familiar with the basics of interacting with a database using.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
PHP Database Processing CIS 1715 Web Technologies.
PHP on a Fast Track a quick introduction to PHP programming by Jarek Francik last time updated in 2012.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
EXAMPLE I An application showing JDBC access to Cloudscape.
Mark Dixon 1 11 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Tasks Needed for MissionMapEditor Martin Q. Zhao September 18, 2010.
Basics of JDBC.
Web Programming Assistant Professor Xiaozhong Liu
Umair Javed©2005 Enterprise Application Development Java Database Connectivity (JDBC) JDBC1.
1 Download current version of Tomcat from: g/tomcat/ g/tomcat/ Install it in: C:\Program Files\Apache.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
JSP/Database Connectivity Instructor: Dr. M. Anwar Hossain.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_Oracle10g_JDBC 1 Application Development (JDBC)
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
MySQL root 암호 $ mysqladmin -u root -p password new-password $ mysql -u root mysql mysql> update user set password = password('new-password') where user.
Database Programming Basic JDBC Programming Concepts.
JSP and DB.
CompSci 280 S Introduction to Software Development
JDBC and OCCI 10/29/2017.
Lec - 14.
JDBC 15-Apr-18.
How to use IoT in Bluemix
Introduction to PHP FdSc Module 109 Server side scripting and
CS320 Web and Internet Programming Database Access with JDBC
Demo : Introduction to BlueMix Sandhya Kapoor May 28, 2014
PHP Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in.
Advanced Web Automation Using Selenium
JDBC 21-Aug-18.
HW#4 Making Simple BBS Using JDBC
DATABASE IN JAVA.
CS5220 Advanced Topics in Web Programming Course Overview
Which Study Material Is Best For IBM C Exam Preparations?
Database Processing with JSP
Introduction to Server-Side Web Development using JSP and Databases
JDBC 15-Nov-18.
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
In Class Assg 2 - solution
2018, Fall Pusan National University Ki-Joune Li
Super Market Management
Lecture 26: Web Security CS /2/2018.
Using a Database with JDBC
PHP: Database connection
Web Programming– UFCFB Lecture
JDBC Example.
CS5220 Advanced Topics in Web Programming Course Overview
Presentation transcript:

IBM BlueMIX pradmenys (aplikacijų talpinimas) (java-mysql; php-mysql atvejai) Autorius: Jonas Skendelis © 2014, Visos teisės saugomos Pastaba: prezentacija parengta 2014 m. pavasarį, tad kai kurie elementai jau pasikeitę, nes Bluemix aplinka vystosi, tačiau patys principai išlikę tie patys. Be to, prezentatacija skirta pateikti „gyvai“, tad greta jos prijungti ir visi pradiniai tekstai.

Debesis – kažkas, kažkur, kažkaip, - pateikiantis tai, ko reikia IBM BlueMIX debesis Debesis – kažkas, kažkur, kažkaip, - pateikiantis tai, ko reikia IBM BlueMIX – PaaS (Platform as a Service) cloud platforma, realizuota Open Source principais (Cloud Foundry), orientuota aplikacijų kūrimui, naudojant Open Source resursus

Šios rezentacijos dėmesio sritys: Liberty for Java, PHP Web sprendimų tipai Šios rezentacijos dėmesio sritys: Liberty for Java, PHP Kitos: Node.js, Python, Ruby ...

Prezentacijos dėmesio sritis: MySQL Leidžiami DB pasirinkimai Prezentacijos dėmesio sritis: MySQL Kitos: NoSQL, DataWorks, ClearDB, ElephantSQL, MongoDB, Postgress...

Taikomoji aplikacija, naudojanti MySQL Legenda: Sukurti aplikaciją BlueMIX terpėje; Sukurti arba prijungti servisą (MySQL); Serviso pasijungimo parametrai (VCAP_SERVICES)

Pasižiūrim „gyvai“ ! …

PHP: Labas, pasauli! Sukuriam „baisiai didelį" PHP puslapį: <!DOCTYPE html> <html><head> <title>PHP: Labas, Pasauli!</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" href="style.css" /> </head> <body> <?php print "<P><B>Labas, Pasauli!</B>"; ?> </body> </html>

... Ir išmetam į „debesis"! Žiūrim kas yra meniu: Start Coding > a) download cf.exe; b) download Starter code; c) Connect to BlueMIX: cf api https://api.ng.bluemix.net d) Login: cf login -u JSkendel@domenas.dm e) Panagrinėjam: manifest.yml f) Upload: cf push PHP-jonas Kiek palaukiam ir .... VISKAS! Patikrinam: http://php-jonas.mybluemix.net/ http://adm-mysql.mybluemix.net/

O dabar ... tebūnie su MySQL Pasijungimo parametrai (VCAP_SERVICES): { "mysql-5.5": [ "name": "mysql-java", "label": "mysql-5.5", "plan": "100", "credentials": { "name": "d47e8ad20fd864e7e8c05075cf643eb9d", "hostname": "75.126.23.246", "host": "75.126.23.246", "port": 3307, "user": “XXXXXX", "username": “UUUUUU", "password": “PPPPPP", "uri": "mysql://UUUUUU:PPPPPP@75.126.23.246:3307/d47e8ad20fd864e7e8c05075cf643eb9d" } ]

PHP: Parodyti MySQL versiją $key = "VCAP_SERVICES"; $value = getenv ( $key ); $vcap_services = json_decode($_ENV["VCAP_SERVICES" ]); $db = $vcap_services->{'mysql-5.5'}[0]->credentials; $mysql_database = $db->name; $mysql_port=$db->port; $mysql_server_name =$db->host . ':' . $db->port; $mysql_username = $db->username; $mysql_password = $db->password; $con = mysql_connect($mysql_server_name, $mysql_username, $mysql_password); if (!$con) { die ('connection failed' . mysql_error()); } $dbselect = mysql_select_db($mysql_database, $con); if ( ! $dbselect ) { echo "<P>ERR:" . mysql_error(); } $strsql = "SELECT VERSION() AS V"; $R = @mysql_query ( $strsql ); echo '<P>Version: '. mysql_result($R, 0, 0) ; mysql_free_result ( $R ); mysql_close();

Būtinas: MySQL Connector/J (jar file) Java sprendimų talpinimas O dabar - tebūnie JAVA ! Būtinas: MySQL Connector/J (jar file)

Java: gauti prisijungimo parametrus import java.util.Map; import java.net.URI; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; // … Map<String, String> env = System.getenv(); String usr, pwd, url; if (env.containsKey("VCAP_SERVICES")) { JSONParser parser = new JSONParser(); JSONObject vcap = (JSONObject)parser.parse(env.get("VCAP_SERVICES")); JSONObject service = null; for (Object key : vcap.keySet()) { String keyStr = (String) key; if (keyStr.toLowerCase().contains("mysql-5.5")) { service = (JSONObject) ((JSONArray) vcap.get(keyStr)).get(0); break; } if (service != null) { JSONObject creds = (JSONObject) service.get("credentials"); URI uri = URI.create((String) creds.get("uri")); url = "jdbc:mysql://" + uri.getHost() + ":" + uri.getPort() + uri.getPath(); usr = uri.getUserInfo().split(":")[0]; pwd = uri.getUserInfo().split(":")[1];

Java: Parodyti MySQL versiją import java.io.InputStream; import java.io.IOException; import java.sql.*; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; … static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; Class.forName(JDBC_DRIVER, true, this.getClass().getClassLoader()); Connection conn = DriverManager.getConnection(url, usr, pwd); Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("SELECT VERSION()"); String outputString = “<P>Labas, MySQL”; if (rs.next()) { outputString = ": version:" + rs.getString(1); } rs.close; st.close(); conn.close();   response.getWriter().println(outputString);

Ir tebūnie šviesa! Palaukiam ir .... VISKAS ! Surenkam viską į vieną vietą; Eksportuojam WAR Peržiūrim manifest.yml Kraunam „debesin“.... cf push JonasFirst -p HelloSQL.war Palaukiam ir .... VISKAS ! Patikrinam: http://jonasfirst.mybluemix.net/HelloSQL

Ačiū už dėmesį ! Pageidaujant prezentacijos „gyvai“ - kreipkitės į jonas.skendelis@yahoo.com Pradinius tekstus galite pasiimti adresu: http://www.lithuanian.net/prezentacijos/sources_bluemix.zip