Services
Application Development
Programming
Website Design Packages
Banner Ad Design

SSS DIGITAL STORE

Products
Shaz Invoice Software
Shaz Password Manager

Portfolio
Sales and Order System
Electronic Diary
Medical Center System
Image Viewer
Website Development

Book Extracts
Design
Quality Assurance
Risk Management
Java Design
SDLC
Processors

Free Source Codes
Free Java Codes
Free C++ Codes
Free Php Scripts

Misc
Creation Theories 1
Creation Theories 2
Words Definition
Search Engine Optimization

Shaz Invoice Software
Downlaod Shaz Invoice Software
Purchase Shaz Invoice Software
Shaz Invoice Software Screen Shots
Shaz Invoice Software Types
Order a Custom Made Invoice

 
Click here to download this Java code.

import java.sql.*;

/* This java class create four tables with all theirs fields and insert them inside a mysql database name timelog. This code works with MySql Database with Mysql Java Connector the mysql-connector-java-3.2.0-alpha */

public class MetaData {
   public static void main(String args[]) {

/*following line initialize a variable to be used for database connection later on in this program. you must change this line properly according to your database name, username, and password.*/

   String url = "jdbc:mysql://localhost/timelog?user=root&password=shaz";

/* The above statement can be written as follows if you do not use user name and password
   String url = "jdbc:mysql://localhost/timelog"; */

   Connection con;
   String createActivity;
   String createContact;
   String createTimeLog;
   String createEmployee;

   createActivity = "create table ACTIVITY " +
       "(activity_id integer not null unique, " +
       "activity_name varchar(20), " +
       "is_predefined char(1), " +
       "task_name varchar(20), " +
       "emp_id varchar(8)," +
       "primary key(activity_id))";

   createContact = "create table CONTACT " +
       "(contact_id varchar(5) not null unique, " +
       "contact_name varchar(20), " +
       "phone varchar(12), " +
       "email varchar(20), " +
       "rating varchar(5)," +
       "primary key(contact_id))";

   createTimeLog = "create table TIMELOG " +
       "(timelog_id integer not null unique, " +
       "start_time timestamp, " +
       "end_time timestamp, " +
       "break_duration integer, " +
       "duration integer," +
       "emp_id varchar(8)," +
       "contact_id varchar(5)," +
       "activity_id integer," +
       "description varchar(20)," +
       "primary key(timelog_id))";

   createEmployee = "create table EMPLOYEE " +
       "(emp_id varchar(8) not null unique, " +
       "emp_name varchar(20), " +
       "primary key(emp_id))";

   Statement stmt;

   try {
      Class.forName("com.mysql.jdbc.Driver"); // format from MySQL Connector/J
   } catch(java.lang.ClassNotFoundException e) {
   System.err.println("ClassNotFoundException: "+ e.getMessage());
   }

   try {
      con = DriverManager.getConnection(url);
      stmt = con.createStatement();
      stmt.executeUpdate(createActivity);
      stmt.executeUpdate(createContact);
      stmt.executeUpdate(createTimeLog);
      stmt.executeUpdate(createEmployee);
      stmt.close();
      con.close();

   } catch(SQLException ex) {
       System.err.println("SQLException: " + ex.getMessage());
       }
   }
   }
 

MySQL Connector Java Mysql JDBC Driver Free Java Training Free Java Program Java Class File Java Database Connectivity Create Database Mysql
Free Java Training Free Java Program Free Java Training Free Java Program Free Java Program Free Java Program Free Java Training
MySQL Connector Java Mysql JDBC Driver Java Class File Java Database Connectivity Create Database Mysql
MySQL Connector Java Mysql JDBC Driver Java Class File Java Database Connectivity Create Database Mysql

Free Web Counter