java 访问access
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class LinkAccess {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Connection con=null;
Statement stmt=null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=E://test//jdbc.mdb";
// "jdbc:odbc:driver={Microsoft Access Driver(*.mdb)};DBQ=D://test//jdbc.mdb";
// 少一个空格都不行。。。
con = DriverManager.getConnection(url,"sa","");
stmt = con.createStatement();
String query = "select * from user";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
System.out.println("connection is ok.");
System.out.println(rs.getInt("id"));
&
相关文档:
eclipse选一个变量后,这个类里的该变量不变色问题解决:
alt + shift + o
/**
* 写入日志
* filePath 日志文件的路径
* code 要写入日志文件的内容
*/
public
static
boolean
print(String filePath,String code) {
try
{
File tofile
=
new
File(filePath);
......
在项目中,我们很多都用到了xml文件,无论是参数配置还是与其它系统的数据交互。
今天就来讲一下Java 中使用dom4j来操作XML文件。
我们需要引入的包:
//文件包
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
//工具包
import java.util.Ite ......
判断一个文件是否为二进制文件
public static boolean isBinary(File file) {
boolean isBinary = false;
try {
FileInputStream fin = new FileInputStream(file);
long len = file.length();
for (int j = 0; j < (int) len; j++) {
int t = fin.read();
......
package stone;
public class PrimerNumber {
public static void main(String[] args) {
int MAX_NUMBER = 100;
boolean[] notPrimer= new boolean[MAX_NUMBER];
for(int i=2;i<=MAX_NUMBER;i++){
if(!notPrimer[i-1]){
for(int j=2*i;j<=MAX_NUMBER;j++){
if(j%i==0) notPrimer[j-1]=tr ......
使用Runtime.getRuntime().exec()方法可以在java程序里运行外部程序.
该方法有6个可访问版本:
1.exec(String command)
2.exec(String command, String envp[], File dir)
3.exec(String cmd, &n ......