Hello Seem to be a hardest word

Just another WordPress.com weblog

PreparedStatement.setTimestamp(1,datetime)

Trong sqlserver có 1 cột DateTime

Trong java nếu dùng preparedStatement rồi thiết lập giá trị cho tham số cho field dateTime này thì nên dùng setTimestamp method.

Ví dụ:
// xem ky hai dong nay
java.sql.Timestamp tstamp = new java.sql.Timestamp(00-00-00);
ps.setTimestamp(5,tstamp.valueOf(“1986-04-02 00:00:00.0″));
Đọc tiếp »

Tháng Tư 7, 2008 Đăng bởi fate | JDBC | | No Comments Yet

Ánh xạ kiểu dữ liệu giữa SQLSERVER và Java

8 Mapping SQL data types into Java

8.1     Constraints

We need to provide reasonable Java mappings for the common SQL data types. We also need to make sure that we have enough type information so that we can correctly store and retrieve parameters and recover results from SQL statements. However, there is no particular reason that the Java data type needs to be exactly isomorphic to the SQL data type. For example, since Java has no fixed length arrays, we can represent both fixed length and variable length SQL arrays as variable length Java arrays. We also felt free to use Java Strings even though they don’t precisely match any of the SQL CHAR types.

Table 2 shows the default Java mapping for various common SQL data types. Not all of these types will necessarily be supported by all databases. The various mappings are described more fully in the following sections.

Đọc tiếp »

Tháng Tư 1, 2008 Đăng bởi fate | JDBC | | No Comments Yet

Cài đặt – Cấu hình – Sử dụng JavaDB (derby)

Tháng Ba 30, 2008 Đăng bởi fate | JDBC | | No Comments Yet

Netbeans Database Application tutorial

Tháng Ba 30, 2008 Đăng bởi fate | JDBC | | No Comments Yet

ElegantJ Data Tables JAVABean

ElegantJ Data Tables JAVABean

Ready to use Table component that has all you wished to have

Be it a 4 row by 10 column table or a table to represent a database in tabular form, or a spreadsheet solution, you can rely on ElegantJ Data Tables Bean. From AWT Data Table and JFC Data Table, select the one that suits your need. Both can handle large volume of data. Get the data filled directly from data source. A cell can be edited as a Textbox, Text Area, Checkbox, Combo box, a Button, an icon, Boolean, etc. Manage data with maximum flexibility using Bean’s formatting, editing, navigating and data handling features. Ready to use Search Panel, functions of insert, add or delete a row as well as column and sorting.

Đọc tiếp »

Tháng Ba 30, 2008 Đăng bởi fate | JDBC | | No Comments Yet

Data Table Components in Sun Java(TM) Studio Creator 2

Background
Sun Java Studio Creator 2 introduced new “basic” components to the Palette, while retaining the JavaServer Faces components the previous version, called “standard” components.

Đọc tiếp »

Tháng Ba 30, 2008 Đăng bởi fate | JDBC | | No Comments Yet

Cập nhật dữ liệu vào CSDL thông qua trung gian ResultSet

Table Mônhọc(MaMon,TenMon,SoTiet)

// Lấy về ResultSet từ table Môn
String s_sql = “select * from tbMon”;
Statement stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stat.executeQuery(s_sql);
Đọc tiếp »

Tháng Ba 27, 2008 Đăng bởi fate | JDBC | | No Comments Yet

Lập Trình Csdl Java-postgresql

DẠO ĐẦU:
JAVA LÀ 1 NGÔN NGỮ – CÔNG NGHỆ LT LÂU ĐỜI , ỔN ĐỊNH. NÓ CÓ THỂ LÀM VIỆC VỚI NHIỀU HỆ QTCSDL KHÁC NHAU NHƯ ORACLE,SQLSERVER,MYSQL,POSGRESQL (THỰC TẾ CÁC CTY CHUỘNG CÁC LOẠI DBMS NÀY NHẤT TRONG SỐ CÁC DBMS)

ORACLE,SQLSERVER,MYSQL ĐA ĐƯỢC NHIỀU NGƯỜI BIẾT ĐẾN, VẬY MINH SẼ HƯỚNG DẪN CÁC BẠN LẬP TRÌNH CSDL TỪ JAVA -> POSGRESQL

ĐIỀU KIỆN CẦN ĐỂ CÓ THỄ THỰC HÀNH CÁC THAO TÁC TRONG BÀI NÀY:

1/ CƠ BẢN JAVA
2/ CƠ BẢN LÝ THUYẾT LẬP TRÌNH CSDL JAVA
3/ CƠ BẢN POSGRESQL HOẶC THAM KHẢO BÀI VIẾT VỀ POSTGRE CŨNG Ở TRONG BLOG NÀY


CÔNG CỤ SỬ DỤNG TRONG BÀI VIẾT NÀY:

TRÌNH CÔNG CỤ TIỆN ÍCH PHÁT TRIỂN JAVA: J2SE5.0/JDK1.5 (NÊN LÀ VERSION NÀY ĐỂ TUONG THÍCH VỚI DRIVER CỦA POSTGRESQL DƯỚI ĐÂY)
www.java.sun.com

bộ cài postgresql (msi), cũng có thể down bộ no-install.zip (tìm trên postgresql.org)

QUOTE

driver của postgresql để lập trình java với jdbc

QUOTE

tài lịeu sử dụng driver trên

QUOTE

THỰC HÀNH:

Đọc tiếp »

Tháng Ba 25, 2008 Đăng bởi fate | JDBC | | No Comments Yet