Mysql And Java Developers Guide Using Java To Connect To MySQL Mohammad Asheri.

Slides:



Advertisements
Similar presentations
CE203 - Application Programming Autumn 2013CE203 Part 51 Part 5.
Advertisements

Basic JDBC Celsina Bignoli What is JDBC Industry standard for database- connectivity between the Java language and a wide range of.
15-Jun-15 JDBC. JDBC is a Sun trademark It is often taken to stand for Java Database Connectivity Java is very standardized, but there are many versions.
1 JDBC Java Database Connectivity. 2 c.pdf
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 32 Java Database.
JDBC. JDBC (Java Database Connectivity): JDBC is an API for the Java programming language that defines how a client may access a database. It provides.
1 Lecture 29 More on JDBC Overview  Objectives of this lecture  JDBC and its Drivers  Connecting to Databases (Java’s Connection class)  Querying a.
Programming for the Web Assignment 1 Help Mark Johnson.
JAdmin: Remote database admin tool. Introduction Growing demand for large scale, multi-user applications –Persistent, efficient, data storage Databases!
TUTORIAL (1) Software installation Written by: Eng. Ahmed Mohamed Abdel Ghafar, Edited by Eng. Muhammed Hammad, Eng. Hamdy Soltan & Eng. Osama Talaat.
JAVA JDBC JAVA JDBC Java Database Programming Lamiaa Said.
Java MS Access database connectivity Follow these steps: 1)Go to the start->Control Panel->Administrative Tools- > data sources. 2)Click Add button and.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 11. DATABASE CONNECTIVITY IN JAVA JDBC Programming JDBC (Java Database Connectivity) is the specification of a.
Introduction to JDBC (Java Database Connectivity).
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
CSCI 6962: Server-side Design and Programming
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Think Possibility Integrating Web Applications With Databases.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
SQL HW1 Turn in as a hardcopy at the start of next class period. You may work this assignment in groups.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
JDBC. JDBC Drivers JDBC is an alternative to ODBC and ADO that provides database access to programs written in Java.
Active Server Pages ASP is Microsoft’s server-side script engine for dynamically-generated web pages. Most common language used is VBScript. If you use.
Georgia Institute of Technology Making Text for the Web part 5 Barb Ericson Georgia Institute of Technology March 2006.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 MySQL and JDBC.
JAVA Database Access. JDBC The Java Database Connectivity (JDBC) API is the industry standard for database- independent connectivity between the Java.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Connecting to Oracle using Java November 4, 2009 David Goldschmidt, Ph.D. David Goldschmidt, Ph.D.
JDBC Java and Databases, including Postgress. JDBC l Developed by Industry leaders l Three main goals: –JDBC should be an SQL-level API –JDBC should capitalize.
 What software components are required?  How do I install the Oracle JDBC driver?  How do I connect to the database?  What form is the data in and.
Introduction to JDBC Michelle Lee, Ye Wu & Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
MySQL & JDCB Αλέξανδρος Καρακασίδης Δεκέμβριος 2004.
JDBC Tutorial CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Copyright © 2002 ProsoftTraining. All rights reserved. Building Database Client Applications Using JDBC 2.0.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 31.1 Reviewing the Bookstore Application 31.2.
Computer Science [3] Java Programming II - Laboratory Course Lab 9: Accessing Databases with JDBC Instructions on Setting Accesses Connecting to and Querying.
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Database Access Using JDBC BCIS 3680 Enterprise Programming.
Connecting to MySQL using Java By:. – Required to use Java.sql so that we can use Connection and Queries using strings. – Javax.swing.* needed for components.
Basics of JDBC.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Web Programming Assistant Professor Xiaozhong Liu
JDBC Java and Databases. SWC – JDBC JDBC – Java DataBase Connectivity An API (i.e. a set of classes and methods), for working with databases in.
1 JDBC – Java Database Connectivity CS , Spring 2010.
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.
Database Processing with JSP ISYS 350. Database Applications Applications Database Server Queries/Updates Results.
JDBC.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
Database Programming Basic JDBC Programming Concepts.
CompSci 280 S Introduction to Software Development
Database: JDBC Overview
JDBC 15-Apr-18.
JDBC Database Management Database connectivity
JDBC – Java Database Connectivity
CS320 Web and Internet Programming Database Access with JDBC
Database JDBC Overview CS Programming Languages for Web Applications
JDBC 21-Aug-18.
JDBC 15-Nov-18.
JDBC – ODBC DRIVERS.
MSIS 655 Advanced Business Applications Programming
Using a Database with JDBC
Java API for Database Connectivity
JDBC Example.
Presentation transcript:

Mysql And Java Developers Guide Using Java To Connect To MySQL Mohammad Asheri

Roadmap Adding Driver To Program Loading The Driver Create Connection Create Statement Execute Query Print Results

Connector J اولین گام برای ایجاد ارتباط بین زبان برنامه نویسی و هر پایگاه داده ای نصب درایور مخصوص آن پایگاه داده است. در اینجا درایور مطلوب Connector j می باشد دو گام اساسی برای نصب : 1) دانلود درایور از سایت مرتبط 2) اضافه کردن درایور به فایل برنامه جاوا

Connector J برای دانلود درایور مرتبط با پایگاه داده MySql به آدرس زیر مراجعه کنید : Connectorj یک فایل با پسوند jar می باشد این فایل به عنوان یک Library به برنامه جاوا شما اضافه میگردد

Connector J In NeatBeans برنامه NetBeans را بازکنید پروژه مطلوب را باز کنید نحوه اضافه کردن درایور مانند ادامه است

Connector J In NeatBeans Right click Select this one

Connector J In NeatBeans 1 2 This window will apear

Connector J In NeatBeans Select your Drivaer.jar

Connector J In NeatBeans

Roadmap Adding Driver To Program Loading The Driver Create Connection Create Statement Execute Query Print Results

Loading… در این مرحله ما باید درایور خود را در برنامه لود کنیم. کد جاوای آن به صورت زیر است : Class.forName("com.mysql.jdbc.Driver").newInstance();

Roadmap Adding Driver To Program Loading The Driver Create Connection Create Statement Execute Query Print Results

Create Connection پس از این که درایور لود شد، باید یک درگاه، کانال یا یک ارتباط بین پایگاه داده و جاوا به منظور تبادل داده ایجاد نمود. ساخت کانکشن در جاوا به شکل زیر است : Connection connection = DriverManager.getConnection(sentence);

Create Connection Sentence در کد قبل به صورت زیر است : "jdbc:mysql://localhost/Database name","user name","password"

Roadmap Adding Driver To Program Loading The Driver Create Connection Create Statement Execute Query Print Results

Create Statement حال برای استفاده از این درگاه ایجاد شده در مرحله قبل ، باید یک شئ از کلاس Statement بسازیم. Statement statement = connection.createStatement(); این شئ دارای متدهای جالبی است که در زیر آمده : executeQuery(…) executeUpdate(…)

Roadmap Adding Driver To Program Loading The Driver Create Connection Create Statement Execute Query Print Results

Execute Query از متد executeQuery(…) می توان برای پرس و جو و گرفتن داده ها از پایگاه استفاده کرد Example : statement.executeQuery("Select * from notebook"); خروجی این سطر یک شئ از کلاس ResultSet می باشد

Execute Query از متد executeUpdate(…) می توان برای اعمالی مانند insert,update,delete از پایگاه استفاده کرد Example : statement.executeUpdate(“inset into notebook …");

Roadmap Adding Driver To Program Loading The Driver Create Connection Create Statement Execute Query Print Results

گفتیم نتیجه پرس و جو به صورت یک شئ از کلاس ResultSet است برای کار با داده های ارسالی از database به صورت زیر عمل می کنیم While(set.next){ set.getType(columnIndex); }

Print Results Example : while(set.next()) { System.out.println(set.getInt(1) + ", " + set.getString(1) + ", " + set.getString(2)); }

Roadmap Adding Driver To Program Loading The Driver Create Connection Create Statement Execute Query Print Results