上一页 1 2 3 4 5 6 7 ··· 14 下一页
摘要: import java.net.URLDecoder; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class ResultSetLike { /** * 取得相对路径的Connection * @return */ public static Connection getConnection(){ Connection conn=null; try{ String path=""; Class theClass = ResultSetLike.class; //System.out.println(ConnTest2.class.getResourceAsStream("db.mdb")); 阅读全文
posted @ 2010-09-02 16:11 叮当小马 阅读(341) 评论(0) 推荐(0)
摘要: import java.net.URLDecoder; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class PrepareStatementTest { /** * 取得相对路径的Connection * @return */ public static Connection getConnection(){ Connection conn=null; try{ String path=""; Class theClass = PrepareStatementTest.class; //System.out.println(ConnTes 阅读全文
posted @ 2010-09-02 16:08 叮当小马 阅读(341) 评论(0) 推荐(0)
摘要: /** * 取得相对路径的Connection * @return */ public static Connection getConnection(){ Connection conn=null; try{ String path=""; Class theClass = ConnTest2.class; //System.out.println(ConnTest2.class.getResourceAsStream("db.mdb")); java.net.URL u= theClass.getResource("db.mdb"); String ChinesePath = URLDecoder.decode(u.getPath().substring(1,u.getPath().length()).replaceAll("%20", " "),"UTF-8"); //System.out.prin 阅读全文
posted @ 2010-09-02 16:05 叮当小马 阅读(337) 评论(0) 推荐(0)
摘要: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class ConnAccessTest { Connection con; String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; String ConnStr = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=E:/workspace/Java从入门到精通/src/第20章数据库操作/db.mdb"; //String ConnStr = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=E:/workspace/db.mdb"; Conne 阅读全文
posted @ 2010-09-02 15:57 叮当小马 阅读(359) 评论(0) 推荐(0)
摘要: import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; public class AnnotationTest { @Field_Method_Parameter_Annotation(describ="字段编号",type=int.class) //注释字段 int id; @Field_Method_Parameter_Annotation(describ="字段姓名",type=String.class)//注释字段 String name; @Constructor_Annotation()//采用默认构造方法 public AnnotationTest() { } @Constructor_Annotation("立即初始化构造方法.") //注释构造方法 public 阅读全文
posted @ 2010-09-01 14:15 叮当小马 阅读(8412) 评论(1) 推荐(1)
摘要: import java.lang.reflect.Field; public class FieldTest { int i; public float f; protected boolean b; private String s; public FieldTest() { i=0; f=0.0f; b = true; s = ""; } public static void main(String[] args){ //进行类实例化: FieldTest fieldTest = new FieldTest(); Field[] declaredFields = FieldTest.class.getDeclaredFields(); for(int i=0;ideclaredFields.length;i++){ Field field = declaredFields[i]; System.out.println("名称为:"+field.getName( 阅读全文
posted @ 2010-09-01 14:10 叮当小马 阅读(6200) 评论(0) 推荐(1)
摘要: import java.lang.reflect.Method; /** * @author Administrator * */ public class MethodTest { static void staticMethod() { System.out.println("执行staticMethod()方法"); } public int publicMethod(int i) { System.out.println("执行publicMethod()方法"); return i*20; } protected int protectedMethod(String s,int i) throws NumberFormatException{ System.out.println("执行protectedMethod()方法"); return Integer.valueOf(s)+i; } private String privateMethod(String...strings){ 阅读全文
posted @ 2010-09-01 14:04 叮当小马 阅读(6641) 评论(0) 推荐(1)
摘要: import java.lang.reflect.Constructor; //请注意执行顺序问题,开始时,我测试时用的是MyEclipse中的Jdk1.5.Jdk1.6我发现他们Constructor的顺序不一样的。 public class ReflectTest { String s; int i,i2,i3; protected ReflectTest() { s=""; i=0; i2=0; i3=0; } protected ReflectTest(String s,int i) { this.s = s; this.i = i; } public ReflectTest(String...strings) throws NumberFormatException //可变数量的参数 { if(0strings.length) { i = Integer.valueOf(strings[0]); } if(1strings.length) { 阅读全文
posted @ 2010-09-01 14:02 叮当小马 阅读(7784) 评论(0) 推荐(0)
摘要: import java.io.*; public class BufferedReaderWriter { public static void main(String[] args) { String content[] = {"好久不见了","最近好吗","常联系"}; File file = new File("E:/workspace/Java从入门到精通/mynote.txt"); try{ FileWriter fw = new FileWriter(file); BufferedWriter bufferfw = new BufferedWriter(fw); for(int k=0;kcontent.length;k++){ bufferfw.write(content[k]); bufferfw.newLine(); } bufferfw.close(); fw.close(); }catch(Exc 阅读全文
posted @ 2010-08-31 20:55 叮当小马 阅读(331) 评论(0) 推荐(0)
摘要: import java.io.*; public class FileInputOutputStream { public static void main(String[] args) { File file = new File("E:/workspace/Java从入门到精通/mynote.txt"); try { FileOutputStream out = new FileOutputStream(file); String str = "程序设计离不开编程语言,但是编程语言在国内的大环境中似乎一直是个二等公民。国内的计算机教育和工程培训,似乎一直在宣传“语言不重要,重要的是思想”,“语言一通百通”等观点,甚至在许多人眼中“语言的讨论”完全是不入流的,但其实“编程语言”与“工具”、“框架”或是“开发方法”等事物一样,都对生产力有着重要的影响。事实上,语言的发展历史比其他方面更为悠久,并且在过去十几年,甚至最近几年中都依然在不断的碰撞,演变。期间一些新的语言诞生了,而另一些在当时看来阳春白雪的语言和编程范式也重新获得了人们的重视。"; 阅读全文
posted @ 2010-08-31 20:52 叮当小马 阅读(276) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 14 下一页