在c/c++中, 我們可以藉由system()執行ㄧ些作業系統上的指令 ,
同樣地 , 在Java中也有屬於自己的方式來進行操作 , 那就是藉由Process與Runtime.exec().
在c/c++中, 我們可以藉由system()執行ㄧ些作業系統上的指令 ,
同樣地 , 在Java中也有屬於自己的方式來進行操作 , 那就是藉由Process與Runtime.exec().
有時在編譯java program時 , 會產生xxx$1.class這樣的檔案 ,
這主要是在該class中含有inner class , 而該inner class被編譯後便會產生xxx$1.class的檔案,
JNA就是Java Native Access , 是為了解決JNI的不便利性所發展出來的
一個 java library , 透過JNA我們可以很簡單的便可以連結到Native shared Library (c/c++的Library).
在Java中 , 要分割String通常我們會用String Class中的split method ,
不過其實還有另外一個class可以幫我們達到這樣的目的 , 那就是StringTokenizer Class.
在Java中 , 除了primitive data type 之外 , 對於所有的物件都是用reference來指向他.
所以當我們宣告一個Object o1時 , 我們等於是宣告一個reference , 而後面我們便可以將o1 reference到任何的compatible type.
We know that we can split the string by the method , split(String regex);
Besides , there is a another overloading function , split(String regex , int limit) , to achieve this purpose.
@法國人 Bioderma 貝德瑪淨妍/新舒妍TS 高效潔膚液500ml ~**2000免郵**超取/黑貓宅配 2011-05-27
☆巴黎草莓☆ NATURACTOR 娜拉兒 遮瑕膏 另有 歐達兒 蓋斑膏/資生堂遮瑕蜜 S100 超商取貨 2012-01-12
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.
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
Before we do any operation for database , we should know how to connect the Mysql database
throuth 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.
When we use vector class , we can use for-each to iterate all elements in the vector container.
import java.util.*;