62,615
社区成员
发帖
与我相关
我的任务
分享
import java.io.*;
//import java.*;
//import java.lang.*;
import java.sql.SQLException;
public class PixInput {
/**
* @param string
* @throws ClassNotFoundException
* @throws SQLException
* @throws SQLException
*/
public static void main(String[] args) throws ClassNotFoundException, SQLException {
if (args.length==0){ //判读路径是否为空
System.out.println("Please input the path");//返回空值错误
}else{
System.out.println("开始导入路径:"+args[0]);//开始导入提示
java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//创建ODBC连接
java.sql.Connection con = null;//声明连接con
try {
con=java.sql.DriverManager.getConnection("jdbc:odbc:pixputin", "sa", "");//设置连接
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("SQLException error...");
e.printStackTrace();
}
java.sql.Statement stmt = null;
try {
stmt=con.createStatement();
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("SQLException1 error...");
e.printStackTrace();
}
int result;
java.lang.String filename;
File inputpath=new File(args[0]);//路径文件赋值
File tempinput;//设置循环用文件
if (inputpath.exists()){
System.out.println("路径检查正确,开始导入...");
//String[] filelist1=inputpath.list();
for (int i=0;i<inputpath.list().length;i++)
{
filename=inputpath.list()[i];
tempinput=new File(filename);//循环文件赋值
if (tempinput.isDirectory()) {
} else{
if ( filename.endsWith("jpg")){
// filename.substring(filename.length()-4, 4)==".jpg") {
System.out.println("正在导入文件:"+inputpath.list()[i]);
result=stmt.executeUpdate("insert into cp(cpbh) values('"+filename.substring(0,filename.length()-4)+"')");
if (result==1) {System.out.println("导入成功!");}
}
}
}
}else{
System.out.println("路径:"+args[0]+"不存在,请检查");
}
stmt.close();
con.close();
}
}
}
/**
* project_name: Test
* package_name: CSDN_Test_20071126
* package_declaration: package CSDN_Test_20071126;
* filename: StringLengthTest.java
* author: yuhaiming
* date: 2007-11-26
*/
package CSDN_Test_20071126;
public class StringLengthTest {
/**
* @param args
*/
public static void main(String[] args) {
//Integer.MAX_VALUE=2147483646
//String[] str = new String[Integer.MAX_VALUE];这么定义肯定超出内存
String[] str = new String[2673];
str[2672]="test";
System.out.println(str[2672]);
}
}