Java

终于搞定 Java 和 MySQL 连接问题

计划就是在元旦假期搞定数据库的大作业, 用 MySQL, 先用 Java 写个能用的界面出来, 如果有时间就去看看能不能把服务器上的首页弄成动态 JSP 的. 加油加油啦.

自己遇见的问题:
在 Java 下从数据库内读出中文显示有乱码, 最后调整一下编码格式就好了.

// String sname = rs.getString("sname");
String sname=new String(rs.getString("sname").getBytes("ISO-8859-1"),"GBK");

就是这里有问题, 从数据库内读出的东西要改变编码格式才能正确显示, 亏我弄了差不多一天来搞这个问题. 谢谢飞飞帮忙搞定 :)

还有一天多的时间, 有空就看看 JSP 然后看能不能搞定 MySQL 和 JSP 的连接, 反正 KO 他们都有做过, 估计能找到源码吧.

Thinking in Java ?

Thinking in Java is a book’s name, a good book. This afternoon, I did a hard work to find a method which can check that a char is a letter or not, but got no answer. I complained that Java is too hard to learn if I don’t know any class library and its method, everything I need to deal by myself, then MagicPig advise us to read the book Thinking in Java, said that it will be the best book to learn Java.

I spent nearly the hole day to type some simple code of the text book, and get many errors some seems strange, there may be a good experiences and wealth, because it can make me not to do the stupid thing again and again. But there is still a little problem need to fixed, which I can’t use Ant in Eclipse to compile a .jar file and to run the .jar file by double-click, there is always a error hint break out when I try to run the .jar file by double-click, I doubt there is something wrong in the build.xml file, but I don’t know how to correct it also I used Baidu and Google for a solution.

Coding in Java

For the course, and for learning a useful skill, start coding in Java. Java is the third programming language I learned strictly, before it are Pascal and C. There is more easy that when you have used a programming language skilled to study another, because the ideas are the same, only the method to get the result are different. The last words may be wrong, because Java is an OO(Object Oriented) language, which is different to the Process-Oriented language likes Pascal/C, and I said I learned C only as I didn’t know the ideas of OO in C++.

In Java, everything is long, the name of class, function, variable, too long to type… I love C, I love VIM, which can do anything use keyboard only. Our Java text book used the Hungarian notation ordinary, so it’s a good way to make my coding habit standardization.