Most operating systems provide program interfaces for performing operations involving the sending and receiving of data over sockets. Most operating systems also provide administrative capabilities to control the amount of memory allocated per socket that is used as data buffers.
- Feb 27 Mon 2012 17:36
Java - java.net.SocketException: No buffer space available
- Feb 27 Mon 2012 15:05
SQL - Primary key
- Feb 27 Mon 2012 12:15
Shell - Arithmetic operation
In Shell programming , we should use $(( )) if we want to do arithmetic operation.
for example :
- Feb 27 Mon 2012 11:06
Shell - String concatenation
Sometimes , we may want to concantenate two string into one string.
It is simple in Shell programming , the example is as below:
- Feb 26 Sun 2012 01:05
MySql - Create a new Account
- Feb 26 Sun 2012 00:59
MySql - 修改密碼
- Feb 25 Sat 2012 16:20
Java - JDBC: Insert Records
- Feb 25 Sat 2012 16:18
Java - JDBC - Create tables
- Feb 25 Sat 2012 16:08
Java - JDBC : create a database
We should send a SQL command if we want the database do some operation.
For example :
//STEP 1. Import required packages import java.sql.*; public class JDBCExample { // JDBC driver name and database URL static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://localhost/"; // Database credentials static final String USER = "username"; static final String PASS = "password"; public static void main(String[] args) { Connection conn = null; Statement stmt = null; try{ //STEP 2: Register JDBC driver Class.forName("com.mysql.jdbc.Driver"); //STEP 3: Open a connection System.out.println("Connecting to database..."); conn = DriverManager.getConnection(DB_URL, USER, PASS); //STEP 4: Execute a query System.out.println("Creating database..."); stmt = conn.createStatement(); String sql = "CREATE DATABASE STUDENTS"; stmt.executeUpdate(sql); System.out.println("Database created successfully..."); }catch(SQLException se){ //Handle errors for JDBC se.printStackTrace(); }catch(Exception e){ //Handle errors for Class.forName e.printStackTrace(); }finally{ //finally block used to close resources try{ if(stmt!=null) stmt.close(); }catch(SQLException se2){ }// nothing we can do try{ if(conn!=null) conn.close(); }catch(SQLException se){ se.printStackTrace(); }//end finally try }//end try System.out.println("Goodbye!"); }//end main }//end JDBCExample |
ref : http://www.tutorialspoint.com/jdbc/jdbc-create-database.htm
- Feb 25 Sat 2012 15:56
Java - JDBC Connection
Before we do any operation for database , we should know how to connect the Mysql database
throuth JDBC.
- Feb 25 Sat 2012 15:21
Java - JDBC
JDBC stands for Java DataBase Connectivity , it is a standard Java API (Application Programming Interface)
for database-independent connectivity between the Java programming language and a wide range of databases.
- Feb 20 Mon 2012 22:13
Java - Vector and for-each
When we use vector class , we can use for-each to iterate all elements in the vector container.
import java.util.*;
- Feb 20 Mon 2012 21:55
Java - Enumeration and Hashtable
- Feb 17 Fri 2012 16:44
cpp - Exception
Exceptions in C++ are implemented using three keywords that work in conjunction with each other: throw, try, and catch.
- Feb 17 Fri 2012 16:33
cpp - Virtual function
A virtual function is a special type of function that resolves to the
most-derived version of the function with the same signature.
- Feb 17 Fri 2012 16:04
cpp - polymorphism
In programming languages, polymorphism means that some code or operations or objects behave differently in different contexts.
For example, the +
(plus) operator in C++:
- Feb 17 Fri 2012 15:52
cpp - inline function
Code written in-place is significantly faster , so C++ offers a way to combine the advantages of functions
with the speed of code written in-place: inline functions.
- Feb 17 Fri 2012 15:39
cpp - read a line
We can read a line by using getline function.
There are two situation , we know the size of a line , or
- Feb 17 Fri 2012 14:19
cpp - Expression parameter
A template expression parameter is a parameter that does not substitute for a type,
but is instead replaced by a value.
- Feb 17 Fri 2012 14:14
cpp - Template class
Template class is similar to function template ,
We can use the template to instead of type of variable or method of class.