Advertisement
Stevenscott

Untitled

May 7th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.09 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 tcf;
  7. import java.sql.*;
  8. /**
  9.  *
  10.  * @author ScottJR
  11.  */
  12. public class Tcf {
  13.     private static final String USERNAME="root";
  14.     private static final String PASSWORD="scooter";
  15.     private static final String CONN_STRING=
  16.             "jdbc:mysql://localhost/Coach_info";
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.  
  22.     Connection conn = null;
  23.    
  24.     try {
  25.         conn = DriverManager.getConnection(CONN_STRING,USERNAME,PASSWORD);
  26.         System.out.println("Connected!!");
  27.         Statement stmt = (Statement) conn.createStatement();
  28.         String Fname="Shawn";
  29.         String Lname="Scott";
  30.         String insert="INSERT INTO basic_info('Fname','Lname')VALUES('"+Fname+"','"+Lname+"')";
  31.         stmt.executeUpdate(insert);
  32.     }catch(SQLException e){
  33.         System.err.println(e);
  34.     }
  35.                
  36.     }
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement