📄 testsql.java
字号:
package org.shaoye.magic;
import org.shaoye.magic.oracle.Execute;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Hashtable;
import org.shaoye.magic.PrimaryKeyObj;
import org.shaoye.magic.Column;
import org.shaoye.magic.reflector.Reflector;
import org.shaoye.magic.TestObj;
/**
* @author zhangt
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class TestSql {
public static void main(String[] args) {
try
{
Class.forName("org.gjt.mm.mysql.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zhangt?user=root;password=root");
/**
* �������
*
Execute e = new Execute(conn, "tbluser");
Hashtable ht = new Hashtable();
ht.put("user_name", "zhangtao");
ht.put("user_id", "zhangt");
//ht.put("d", new java.util.Date());
e.add(ht);
**/
/**
* ������
*/
Execute e = new Execute(conn, "test_tbl");
Hashtable ht = new Hashtable();
ht.put("str", "tao_zhang");
ht.put("age", new Integer(26));
ht.put("grp", "001");
//e.set(ht);
PrimaryKeyObj obj = new PrimaryKeyObj();
Column col = new Column();
col.setName("id");
col.setDefaultValue("zhang403");
obj.addPrimaryKey(col);
col = new Column();
col.setName("grp");
col.setDefaultValue("001");
obj.addPrimaryKey(col);
//java.util.List list = new java.util.ArrayList();
//list.add( obj );
//e.set(obj,ht);
//e.remove( list );
//ht = ( Hashtable )e.get(obj);
//System.out.println( ht.get("id") );
//e.remove("hawk");
//ht=(Hashtable)e.get("hawk");
java.util.ArrayList list = (java.util.ArrayList)e.getAllItem();
System.out.println(list.size());
/**/
e.destroy();
}
catch( ClassNotFoundException clex )
{
clex.printStackTrace();
}
catch( SQLException se )
{
se.printStackTrace();
System.out.println("SQLException"+se.toString());
}finally
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -