⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testbcp.java

📁 一个支持微软sqlserver 2000 数据库的jdbc驱动程序
💻 JAVA
字号:
import java.sql.*;import java.util.*;import java.io.FileOutputStream;import java.io.FileDescriptor;import java.io.BufferedOutputStream;import java.io.PrintStream;import net.sourceforge.jtds.jdbc.*;public class TestBCP{	public class GetoptParser	{		private HashMap opts = new HashMap();		public GetoptParser(String options, String [] args)		{			for (int i=0; i < args.length; i++)			{				if (args[i].startsWith("-"))				{					if (args[i].length() > 2)					{						opts.put(args[i].substring(0,2), args[i].substring(2));					}					else					{						opts.put(args[i], "1");					}				}								} 		}		public String getopt(String opt)		{			return ((String) opts.get(opt));		}	}	public static void main(String[] args) 		throws Exception	{		FileOutputStream fdout = new FileOutputStream(FileDescriptor.out);		BufferedOutputStream bos = new BufferedOutputStream(fdout, 2048);		PrintStream ps = new PrintStream(bos, true);    		System.setOut(ps);		TestBCP bcp = new TestBCP(args);	}	public TestBCP(String [] args)		throws ClassNotFoundException, java.io.FileNotFoundException, java.io.IOException, java.lang.Exception	{		String username, password, delimiter;		int batchSize = 1000;		int debug = 0;		if (args.length < 2)		{			System.out.println("Usage: jbcp database..table file -Sserver -Uusername -Ppassword ");			System.exit (1);		}		GetoptParser gop = new GetoptParser("b:d:", args);		batchSize	= (gop.getopt("-b") == null) ? 1000 : (new Integer((String) gop.getopt("-b"))).intValue();		debug		= (gop.getopt("-d") == null) ? 1000 : (new Integer((String) gop.getopt("-d"))).intValue();		username	= (gop.getopt("-U") == null) ? null : gop.getopt("-U");		password	= (gop.getopt("-P") == null) ? null : gop.getopt("-P");		delimiter	= (gop.getopt("-t") == null) ? null : gop.getopt("-t");		try 		{			//String dbUrl= "jdbc:jbcp:sybase://<db>:<port>/";			String dbUrl= "jdbc:jbcp:sybase://<host>:<port>/";			int dotpos	= args[0].indexOf(".");			String db	= args[0].substring(0, dotpos);			String table	= args[0].substring(dotpos+2);			System.out.println("DB url = " + dbUrl + db);			Class.forName("net.sourceforge.jtds.jdbc.Driver");			BCP bcp = (BCP) DriverManager.getConnection (dbUrl + db, username, password);			bcp.setDebug(debug);			System.out.println("doing config; delimiter = " + delimiter);			// args[1] = filename args[0] = tablename			bcp.config(args[1], args[1] + ".err", table, batchSize, delimiter);			bcp.run();		}		catch (java.sql.SQLException e)		{			throw new Exception(e);		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -