MySQL root 암호 $ mysqladmin -u root -p password new-password $ mysql -u root mysql mysql> update user set password = password('new-password') where user.

Slides:



Advertisements
Similar presentations
Basic JDBC Celsina Bignoli What is JDBC Industry standard for database- connectivity between the Java language and a wide range of.
Advertisements

1 Lecture 05: Database Programming (JDBC). 2 Outline JDBC overview JDBC API Reading: Chapter 10.5 PostgreSQL JDBC interface documentation
JDBC. Java Database Connectivity (JDBC) Use the java.sql package to query and update the database. JDBC is an API that allows java to communicate with.
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: Part I Attribution These slides are based on three primary sources: –Sun JDBC Tutorial URL: jdbc/TOC.htmlhttp://java.sun.com/docs/books/tutorial/
JDBC Overview Autumn 2001 Lecturer: C. DeJong. Relational Databases widespread use used via SQL (Structured Query Language) freely available powerful.
Object-Oriented Enterprise Application Development Introduction to JDBC.
Advanced Java Programming – Eran Toch Methodologies in Information System Development Tutorial: Advanced Java Programming and Database connection Eran.
Three-Tier Architecture Oracle DB Server Apache Tomcat App Server Microsoft Internet Explorer HTML Tuples HTTP Requests JDBC Requests Java Server Pages.
UFCE4Y UFCE4Y-20-3 Components and Services Julia Dawson.
Java MS Access database connectivity Follow these steps: 1)Go to the start->Control Panel->Administrative Tools- > data sources. 2)Click Add button and.
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
CS178 Database Management “JDBC”. What is JDBC ? JDBC stands for “Java DataBase Connectivity” The standard interface for communication between a Java.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
Beginning Databases with JDBC Mike Bradley Adapted from and notes by Kevin Parker, Ph.D.
Dr. Magdi AMER Unit 2 Introduction to Database. Intro Many programs need to save information on disk. The role of DB system is to provide a layer of abstraction.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
JDBC (Java Database Connectivity) SNU OOPSLA Lab. October 2005.
JAVA Database Access. JDBC The Java Database Connectivity (JDBC) API is the industry standard for database- independent connectivity between the Java.
JDBC. JDBC stands for Java Data Base Connectivity. JDBC is different from ODBC in that – JDBC is written in Java (hence is platform independent, object.
JDBC  The JDBC (Java Database Connectivity) API helps a Java program to access a database in a standard way  JDBC is a specification that tells the.
JSP program that interacts with HTML form & Access Data Base.
Accessing Database using JDBC. JDBC Objectives Gain basic knowledge of Java JDBC Become familiar with the basics of interacting with a database using.
JDBC. A Basic MySQL Tutorial MySQL is an open source database management software that helps users store, organize, and retrieve data. It is a very powerful.
Chapter 25 Databases. Chapter Scope Database concepts Tables and queries SQL statements Managing data in a database Java Foundations, 3rd Edition, Lewis/DePasquale/Chase25.
JDBC. Java.sql.package The java.sql package contains various interfaces and classes used by the JDBC API. This collection of interfaces and classes enable.
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
Presentation On How To Create Connection To A Database.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
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.
16 Java Database Connectivity. 2 Understand the JDBC Understand the steps of the JDBC: 1.) Importing packages 2.) Opening a connection to a database 3.)
Tasks Needed for MissionMapEditor Martin Q. Zhao September 18, 2010.
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Basics of JDBC.
Web Programming Assistant Professor Xiaozhong Liu
Umair Javed©2005 Enterprise Application Development Java Database Connectivity (JDBC) JDBC1.
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.
JDBC Statements The JDBC Statement, CallableStatement, and PreparedStatement interfaces define the methods and properties that enables to send SQL or PL/SQL.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java program to connect to any database.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
Database Programming Basic JDBC Programming Concepts.
MYSQL APPLICATIONS USING JAVA & JDBC CIS 430 –Database Concepts Victor Matos.
JSP and DB.
CS JDBC.
JDBC and OCCI 10/29/2017.
Java Access to RDB Relational databases (RDBs) dominate today, due to:
Interacting with Database
1st Semester, 2017 Sanghyun Park
Lec - 14.
JDBC 15-Apr-18.
CS320 Web and Internet Programming Database Access with JDBC
JDBC 21-Aug-18.
HW#4 Making Simple BBS Using JDBC
Prof: Dr. Shu-Ching Chen TA: Sheng Guan
Introduction to Server-Side Web Development using JSP and Databases
JDBC 15-Nov-18.
Objectives In this lesson, you will learn about:
Interacting with Database
Database Programming Using JDBC and MySQL C API
Using a Database with JDBC
JDBC API.
JDBC Example.
CS3220 Web and Internet Programming Database Access with JDBC
CS3220 Web and Internet Programming Database Access with JDBC
Java Chapter 6 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

MySQL root 암호 $ mysqladmin -u root -p password new-password $ mysql -u root mysql mysql> update user set password = password('new-password') where user = 'root'; mysql> flush privileges; mysql> set password for root = password('new-password'); $ mysql -u root -p

MySQL DB 생성 myslq> show databases; mysql> create database DB 명 ;

MySQL 사용자 추가 mysql> use mysql mysql> INSERT INTO user VALUES('%', ' 사용자 ', PASSWORD(' 비밀번호 '), -> 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y'); mysql> INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv) -> VALUES('%', 'DB 명 ', ' 사용자 ', 'Y', 'Y', 'Y', 'Y','Y','Y'); mysql> grant all privileges on dbuser.* to identified by 'password' with grant option; mysql> grant all privileges on `dbuser_%`.* to identified by 'password' with grant option; mysql> GRANT ALL on DB 명.* TO ; mysql> GRANT ALL on DB 명.* TO id; mysql> GRANT ALL on DB 명.* TO % 는 부분적 모든 * 는 모든

import java.sql.*; public class Connect { public static void main (String[] args) { Connection conn = null; try { String userName = "testuser"; String password = "testpass"; String url = "jdbc:mysql://localhost/test"; Class.forName ("com.mysql.jdbc.Driver").newInstance (); conn = DriverManager.getConnection (url, userName, password); System.out.println ("Database connection established"); } catch (Exception e) { System.err.println ("Cannot connect to database server"); } finally { if (conn != null) { try { conn.close (); System.out.println ("Database connection terminated"); } catch (Exception e) { /* ignore close errors */ } } forName: 해당 클래스가 존재하면 그 클래스를 리턴함 newInstance: 클래스의 인스턴스를 생성함 public static Connection getConnection(String url, String user, String password) throws SQLExceptionConnectionString SQLException

Statement s = conn.createStatement (); int count; s.executeUpdate ("DROP TABLE IF EXISTS animal"); s.executeUpdate ( "CREATE TABLE animal (" + "id INT UNSIGNED NOT NULL AUTO_INCREMENT," + "PRIMARY KEY (id)," + "name CHAR(40), category CHAR(40))"); count = s.executeUpdate ( "INSERT INTO animal (name, category)" + " VALUES" + "('snake', 'reptile')," + "('frog', 'amphibian')," + "('tuna', 'fish')," + "('racoon', 'mammal')"); s.close (); System.out.println (count + " rows were inserted"); StatementStatement createStatement() throws SQLExceptionSQLException int executeUpdate(String sql) throws SQLExceptionStringSQLException Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

Statement s = conn.createStatement (); s.executeQuery ("SELECT id, name, category FROM animal"); ResultSet rs = s.getResultSet (); int count = 0; while (rs.next ()) { int idVal = rs.getInt ("id"); String nameVal = rs.getString ("name"); String catVal = rs.getString ("category"); System.out.println ( "id = " + idVal + ", name = " + nameVal + ", category = " + catVal); ++count; } rs.close (); s.close (); System.out.println (count + " rows were retrieved"); ResultSetResultSet executeQuery(String sql) throws SQLExceptionStringSQLException Executes the given SQL statement, which returns a single ResultSet object. ResultSetResultSet getResultSet() throws SQLExceptionSQLException Retrieves the current result as a ResultSet object. This method should be called only once per result. boolean next() throws SQLExceptionSQLException Moves the cursor froward one row from its current position. A ResultSet cursor is initially positioned before the first row; int getInt(String columnLabel) throws SQLExceptionStringSQLException Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language. StringString getString(String columnLabel) throws SQLExceptionStringSQLException Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language. PreparedStatement s; s = conn.prepareStatement ( "INSERT INTO animal (name, category) VALUES(?,?)"); s.setString (1, nameVal); s.setString (2, catVal); int count = s.executeUpdate (); s.close (); System.out.println (count + " rows were inserted");

import java.sql.*; public class Hello { public static void main(String[] args) { try { // The newInstance() call is a work around for some // broken Java implementations Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (Exception ex) { // handle the error } Connection conn = null; try{ conn = DriverManager.getConnection("jdbc:mysql://localhost", "bjkim","qudwlsl1"); } catch (SQLException ex) { // handle any errors System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } Statement stmt = null; ResultSet rs = null; try{ stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT * FROM test.user"); // or alternatively, if you don't know ahead of time that // the query will be a SELECT... if (stmt.execute("SELECT * FROM test.user")) { rs = stmt.getResultSet(); } } catch(Exception ex) { // handle the error } try{ while (rs.next()) { int id = rs.getInt("id"); String name = rs.getString("name"); int age = rs.getInt("age"); System.out.println(id + " " + name + " " +age); } }catch(Exception ex) { // handle the error } }

MyMessenger gui 작성