Advertisement
Guest User

Untitled

a guest
May 21st, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package basedados;
  7.  
  8. import java.sql.*;
  9.  
  10. /**
  11.  *
  12.  * @author Henrique
  13.  */
  14. public class BaseDados {
  15.  
  16.     /**
  17.      * @param args the command line arguments
  18.      */
  19.     public static void main(String[] args) {
  20.         Connection conn = null;
  21.        
  22.         try{
  23.             conn=DriverManager.getConnection("root","root","jdbc:mysql://localhost:8889/youTube");
  24.             Statement stnt= (Statement) conn.createStatement();
  25.             String Fname = "Jane";
  26.             String Lname = "Brown";
  27.             String insert = "INSERT INTO 'youtube'.'user'('Fname','Lname') VALUES ('"+Fname+"','"+Lname+"')";
  28.             stnt.executeUpdate(insert);
  29.         }catch (SQLException e){
  30.             System.err.println(e);
  31.         }
  32.     }
  33.    
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement