易截截图软件、单文件、免安装、纯绿色、仅160KB

An agile dynamic language for the Java Platform

 Groovy supports a few neat ways to work with SQL more easily and to make SQL more Groovy. You can perform queries and SQL statements, passing in variables easily with proper handling of statements, connections and exception handling thanks to closures.
import groovy.sql.Sql
def foo = 'cheese'
def sql = Sql.newInstance("jdbc:mysql://localhost:3306/mydb", "user",
"pswd", "com.mysql.jdbc.Driver")
sql.eachRow("select * from FOOD where type=${foo}") {
println "Gromit likes ${it.name}"
}
In the above example, you can refer to the various columns by name, using the property syntax on the row variable (e.g. it.name) or you can refer to the columns by their index (e.g. it[0]) For example:
import groovy.sql.Sql
def foo = 'cheese'
def sql = Sql.newInstance("jdbc:mysql://localhost:3306/mydb", "user",
"pswd", "com.mysql.jdbc.Driver")
def answer = 0
sql.eachRow("select count(*) from FOOD where type=${foo}") { row ->
answer = row[0]
}
assert answer > 0
Or you can create a DataSet which allows you to query SQL using familar closure syntax so that the same query could work easily on in memory objects or via SQL. e.g.
import groovy.sql.Sql
def sql = Sql.newInstance("jdbc:mysql://localhost:3306/mydb", "user",
"pswd", "com.mysql.jdbc.Driver")
def food = sql.dataSet('FOOD')
def cheese = food.findAll { it.type == 'cheese' }
cheese.each { println "Eat ${it.name}" }
Advanced Usage
In this example, we create a table, make changes to it and confirm the changes worked.
def sql = Sql.newInstance("jdbc:mysql://localhost:3306/mydb",
"user", "pswd", "com.mysql.jdbc.Driver")
// delete table if previously created
try {
sql.execute("drop table PERSON")
} catch(Exception e){}
// create table
sql.execute('''create table PERSON (
id integer not null primary key,
firstname varchar(20),
lastname varchar(20),
location_id integer,
location_name varch


相关文档:

WindowsMobile系统管理java插件

       WindowsMobile系统无法直接管理JAVA插件,需要借助JAVA虚拟机来管理JAVA插件,WM平台常见的JAVA虚拟机有Jbed和Jblend。下面就WM平台管理JAVA插件做简要介绍。
1、Jbed
Esmertec公司的产品,外部命令管理方式为:
安装:\Windows\jbed.exe -DFile.maxStorageSize=64M -ginstall \" ......

Java相对路径/绝对路径总结 (转)

1.基本概念的理解
绝对路径:绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:
C:xyz est.txt 代表了test.txt文件的绝对路径。http://www.sun.com/index.htm也代表了一个URL绝对路径。
相对路径:相对与某个基准目录的路径。包含Web的相对路径(HTML中的相对目录),例如:在
Servlet中, ......

Java中JList简单应用

 最近学习java用到了JList,对于向JList中添加数据,困扰了好久,上网查给的答案都没个合适的,问了老师才弄明白些,总结如下:
1.使用Vector:首先把你的数据项都存放在Vector中,然后调用JList的setListData()方法,将Vector添加到JList中
   Vector vt=new Vector();
   JList list=new JLis ......

java中涉及构造器的相关问题

            在看到Thinking in java 第四章时初始化相关问题的时候,我们不由地把注意力移到构造器上。这里做个简单的总结,便于高手指正以及自己温故。
      首先构造器是要构造一个东西{构造对象(实例)}并对其初始化。之所以 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号