Windows/DOS commands

  1. Show the path variable: echo %path%
  2. list directories and files: dir. list one screen at a time: dir /p list item with sizes(recursive): dir /s. the / tags can follow (/s /p)
  3. print characters to the screen: echo
  4. Pause a batch with an option to abort: pause
  5. Copy file: copy
  6. Outputting data to a file instead of the screen (e.g. the dir command) dir >myfile.txt
  7. Delete file(s):del
  8. Display time: time. will also let you change it, so be careful!
  9. Display the date: date. will also let you change it, so be careful!
  10. Show command history:doskey. This is the default for modern Windows versions.
  11. Comparing two files: fc.

JDBC java and mysql

first you must include the sql package:

import java.sql.*;

In order to word with JDBC driver for mysql, you first need to load the driver:

String driver = “com.mysql.jdbc.Driver”;
Class.forName(driver).newInstance();

Next there are minimum of item you must declare:

Connection conn = null;
Statement st = null;

Now, lets connect:

String url = “jdbc:mysql://” + server_name + “:3306/”;

try
        {
            conn = DriverManager.getConnection(url + db_name, username, password);
        } catch (SQLException ex)
        {
            Logger.getLogger(MySQLtest.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("fail to open mysql connection");
            return;
        }

where password, username, server_name and db_name are all strings you get from user input/file and so on.

next you need to create a statement:

try
        {

            st = conn.createStatement();
        } catch (SQLException ex)
        {
            Logger.getLogger(MySQLtest.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }

to view results or record sets, you can call the Execute XXX method, where XXX stands for the specific flavour you need (create, update, count or select).

more info on the statement class here.