2008年11月26日星期三

在JSP中访问数据库示例

将jdbc的驱动程序放到服务器的类路径里,然后要在数据库里建一个表test,有两个字段比如为test1,test2,可以用下面SQL建 create table test(test1 varchar(20),test2 varchar(20),然后向这个表写入一条测试纪录,那么现在开始我们的jsp和数据库之旅吧。

  一、jsp连接Oracle8/8i/9i数据库(用thin模式)

testoracle.jsp如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orcl为你的数据库的SID
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

  二、jsp连接Sql Server7.0/2000数据库


testsqlserver.jsp如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
//pubs为你的数据库的
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

  三、jsp连接DB2数据库


testdb2.jsp如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url="jdbc:db2://localhost:5000/sample";
//sample为你的数据库名
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

  四、jsp连接Informix数据库


testinformix.jsp如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url =
"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword";
//testDB为你的数据库名
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

  五、jsp连接Access数据库


<%@page import="java.sql.*"
import ="java.util.*"
import ="java.io.*"
import="java.text.*"
contentType="text/html; charset=gb2312"
buffer="20kb"
%><%! int all,i,m_count;
String odbcQuery;
Connection odbcconn;
Statement odbcstmt;
ResultSet odbcrs;
String username,title,content,work,email,url,time,date;
String datetime;
%>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch (ClassNotFoundException e)
{ out.print ("驱动程序不存在");
}
try{
odbcconn = DriverManager.getConnection("jdbc:odbc:db1");
odbcstmt = odbcconn.createStatement();
odbcQuery="Select * From book where datetime>2001-4-26 Order By datetime DESC";
odbcrs=odbcstmt.executeQuery(odbcQuery);
int i=0;
while (i<130) odbcrs.next();
while (odbcrs.next())
{
//*/////////////////////////显示数据库的内容用于调试程序是用//
int ii;
try{
try{
for (ii=1;;ii++)
out.print ("<br>Cloumn "+ii+" is: "+odbcrs.getString(ii));
}catch (NullPointerException e) {
out.print ("有空的指针");
}
}catch (SQLException e){
}
}
odbcrs.close();
odbcstmt.close();
odbcconn.close();
}catch (SQLException e)
{ out.print (e);
}
%>

2008年11月18日星期二

Senior technical lead

Job ID: SWG-0186873
Job type: Full-time Regular
Work country: China
Posted: 10-Sep-2008
Work city: Shanghai
Job area: Software Development
Travel: up to 10%; travelling 1 day a week
Job category: Software Development & Support
Business unit: WPLC
Job role: Technical Support Professional
Job role skillset: General
Job description BU Description:IBM Workplace Portal and Collaboration (WPLC - Lotus)

BU is responsible for developing IBM's collaborative technology and solutions which integrate people, data and business processes to create the "human side" of IBM's On Demand and SOA strategies. We are inviting talents to share our enjoyment of developing Lotus Mashups, one of components of IBM Mashup Center. IBM Mashup Center, as the first integrated enterprise Web 2.0 mashup software platform in the industry, is a complete end-to-end mashup platform, supporting line-of-business assembly of simple, flexible, and dynamic Web applications, with the management, security, and governance capabilities that IT requires. Within this project, developers/testers will have opportunity to develop deep skills and knowledge in J2EE, Web2.0, and will work closely with worldwide senior technical people.

Developer lead:
• Lead the communication and collaboration with worldwide labs, and facilitate conference call with US teams.
• Analyze requirements, design and implementation of new features.
• Develop full owned code for product new release
• Work across organization boundaries to achieve objectives.
• Work as a technical leader to either lead a team to complete the software development project tasks..
• Passionate to software development. An independent, assertive, self-motivated, creative, dynamic, and flexible approach is required, whilst offering and open to new ideas.

Tech Skills:
• Rich programming skills in Java, J2EE, and AJAX
http://en.wikipedia.org/wiki/Ajax_(programming)
http://en.wikipedia.org/wiki/J2ee
• Familiar with software development and software development process
• Solid Knowledge or rich experiences in following fields is a strong plus:
• Web Application Development -- HTML/CSS/JavaScript/JSP
• Hands-on experience on AJAX framework/toolkits such as Dojo, jQuery, YUI, prototype, etc.
http://en.wikipedia.org/wiki/List_of_Ajax_frameworks
• OGSI, eclipse equinox

• WebSphere Application Server public Java API and programming extensions
• iBatis/Hibernate. IBM DB2, Oracle, Microsoft SQL Server
http://ibatis.apache.org/
http://en.wikipedia.org/wiki/Hibernate_(Java)

Soft Skills
• Strong English communication in writing, listening and speaking
• Strong technique leadership and assertive thinking
• Strong communication and team work skills
• Self-motivated
• Strong analytical and troubleshooting skills
• Quick learner and good flexibility
• Having strong sense of ownership and high accountabilityMaster degree or above in Computer Science & Technology or equivalent,

Required
Master's Degree
English: Fluent
Chinese simplified: Fluent

IBM is committed to creating a diverse environment and is proud to be an equal opportunity employer. All qualified applicants will receive consideration for employment without regard to race, color, religion, gender, gender identity or expression, sexual orientation, national origin, genetics, disability, age, or veteran status.

2008年11月14日星期五

视频终端的参数设置

1、基本参数
视频设备,尺寸,帧率,画质
麦克风设备,音量
扬声器设备,音量
带宽

2、H.323
GK地址,用户名,密码,E164

3、SIP
sip server,sip名

4、VMEET
server,ID,password

2008年11月11日星期二

使用OpenSSL制作PKI数字证书

十年前就使用过OpenSSL了,这个加密工具和算法包非常强大和丰富。不过至今仍不能清楚记得命令行的具体参数,需要用的时候总免不了要翻翻手册,这里做一个简单的笔记。

1.首先要生成服务器端的私钥(key文件):
openssl genrsa -des3 -out server.key 1024
运行时会提示输入密码,此密码用于加密key文件(参数des3便是指加密算法,当然也可以选用其他你认为安全的算法.),以后每当需读取此文件(通过openssl提供的命令或API)都需输入口令.如果觉得不方便,也可以去除这个口令,但一定要采取其他的保护措施!
去除key文件口令的命令:
openssl rsa -in server.key -out server.key

2.openssl req -new -key server.key -out server.csr -config openssl.cnf
生成Certificate Signing Request(CSR),生成的csr文件交给CA签名后形成服务端自己的证书.屏幕上将有提示,依照其指示一步一步输入要求的个人信息即可.

3.对客户端也作同样的命令生成key及csr文件:
openssl genrsa -des3 -out client.key 1024
openssl req -new -key client.key -out client.csr -config openssl.cnf

4.CSR文件必须有CA的签名才可形成证书.可将此文件发送到verisign等地方由它验证,要交一大笔钱,何不自己做CA呢.
openssl req -new -x509 -keyout ca.key -out ca.crt -config openssl.cnf

5.用生成的CA的证书为刚才生成的server.csr,client.csr文件签名:
Openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config openssl.cnf
Openssl ca -in client.csr -out client.crt -cert ca.crt -keyfile ca.key -config openssl.cnf

现在我们所需的全部文件便生成了.

另:
client使用的文件有:ca.crt,client.crt,client.key
server使用的文件有:ca.crt,server.crt,server.key

.crt文件和.key可以合到一个文件里面,把2个文件合成了一个.pem文件,直接拷贝过去即可。

IBM技术以及职位相关信息

软件下载资源中心
http://www.ibm.com/developerworks/cn/downloads/index.html

Eclipse开发环境开源项目
http://www.eclipse.org/

IBM职位招聘信息
https://jobs3.netmedia1.com/cp/search.jsp?tc=1199340560188

IBM IT架构师职位要求 链接

2008年10月20日星期一

如何在Vista上安装.NET 1.1

Windows Vista comes packaged with Microsoft .NET Framework 2.0 and 3.0, but not version .NET 1.1, which may still required by some applications such as QuickBooks 7, GFI Report Packs, VS.NET 2003, InstallShield 11.5, and many other developed software.

However, when trying to install Microsoft .NET Framework 1.1 (dotnetfx.exe) on Windows Vista, one or more error messages similar to one of the following text will appear, and stop or prevent setup installation of .NET Framework 1.1 from continuing successfully.

  • RegSvcs.exe - Common Language Runtime Debugging Services
    Application has generated an exception that could not be handled.Process id=0xe50 (3664), Thread id=0xd44 (3396).
    Click OK to terminate the application.Click CANCEL to debug the application.
    If user click “OK’, the installation of .NET 1.1 will be cancelled, while clicking “CANCEL” produces another error message similar to below:
  • RegSvcs.exe - No debugger found
    Registered JIT debugger is not available. An attempt to launch a JIT debugger with the following command resulted in an error code of 0×2 (s). Please check computer settings.
    cardbg.exe !a 9×8e

In Even Viewer of Vista, the following log or similar can be seen:

  • Source: MsiInstallerEvent ID: 1030Description:Product: Microsoft .NET Framework 1.1. The application tried to install a more recent version of the protected Windows file C:\Windows\Microsoft.NET\Framework\sbs_wminet_utils.dll. You may need to update your operating system for this application to work correctly. (Package Version: 1.0.0.0, Operating System Protected Version: 1.0.0.0).
  • Source: MsiInstallerEvent ID: 1030Description:Product: Microsoft .NET Framework 1.1. The application tried to install a more recent version of the protected Windows file C:\Windows\Microsoft.NET\Framework\sbs_system.enterpriseservices.dll. You may need to update your operating system for this application to work correctly. (Package Version: 1.0.0.0, Operating System Protected Version: 1.0.0.0).
The error pops up in the end of .NET Framework 1.1 setup when it’s almost finished, and is registering “System.EnterpriseServices.dll” when the error occurs, time remaining for the installatin process shows 0 seconds.


Why exactly the error occurs when installing Microsoft .NET Framework 1.1 in Windows Vista is not known, as the issue happens randomly. It may affect both 32-bit and 64-bit Vista system, but not all system will have the issue. But one thing is for sure. Microsoft .NET Framework 1.1 SP1 (Service Pack 1) has resolved the issue. However, Microsoft does not provide download to standalone .NET Framework 1.1 installer that integrated with SP1.

Thus, the workaround to fix the Microsoft.NET Framework 1.1. installation error on Vista is to slipstream .NET Framework 1.1 SP1 into .NET Framework 1.1 installer, so that both the .NET Framework and the Service Pack can be installed at the same time.

To slipstream .NET 1.1 SP1 into .NET Framework setup package to have a integrated .NET Framework 1.1 SP1 installer, follow steps in this trick:

1. Create a new folder named DotNet in C:\ drive (C:\DotNet is used in this guide, you can change to any folder you prefer, but ensure that you use correct path in the following steps).
2. Download Microsoft .NET Framework 1.1 Redistributable Package (dotnetfx.exe). Make sure the setup file is saved as dotnetfx.exe.
3. Download Microsoft .NET Framework 1.1 Service Pack 1 (NDP1.1sp1-KB867460-X86.exe). Make sure that the file is renamed and saved as dotnetfxsp1.exe, so that the rest of the steps can be followed easily.
4. Move both installation files into the same directory (i.e. C:\DotNet), if you’re not saving them together.
5. Open command prompt as Administrator.
6. Change to the directory where the two installation setup files for .NET 1.1 are saved (i.e. C:\DotNet).

7. Run the following commands one by one, press Enter after each one.

dotnetfx.exe /c:"msiexec.exe /a netfx.msi TARGETDIR=C:\DotNet"
If you’re not using C:\DotNet directory, change the target to your path accordingly.
Then click on “Yes” when prompted to answer “would you like to install Microsoft .NET Framework 1.1. Package?”
Wait for the uncompression, extraction and setup to complete with the display of the following dialog which says installation complete.

dotnetfxsp1.exe /Xp:C:\DotNet\netfxsp.msp
No status message for this step.

msiexec.exe /a c:\DotNet\netfx.msi /p c:\DotNet\netfxsp.msp
Wait for Windows Installer for Microsoft .NET Framework 1.1 to finish and disappear automatically.

Install Microsoft .Net Framework 1.1 with slipstreamed/integrated Service Pack 1 by running netfx.msi created in the working folder.
netfix.msi

现在用Vista安装了VS2003后出现了一个严重的问题,使用Find In Files功能时, VS2003会停止响应。上网找相关信息,有人已经报告这个问题了。不过MS说不管VS2003了。

后来发现了另外一台VISTA的电脑不存在这个问题,一对比原来是Windows Themes的问题。只要把Windows外观,改成比较难看的标准模式(就像WIN2000那样...)就能把问题解决掉了。

用Microsoft Cluster实现服务器群集

  大网站每天承受上千万的访问量,而服务器却依然能够应付自如;网络空间服务商所提供的大量空间,而却收费低廉,的确这些情况有点让人难以理解,难道天下真的有性能如此之高的服务器单机?其实则不然,支持这些大量访问和无数数据请求的是服务器群集。
  服务器群集是由一组各自独立的服务器连接而成,利用硬件和软件合理分配网络负荷,达到提高整体服务性能的服务器的集合。
  那么如何架设服务器群集呢?其过程并不复杂,利用Windows2000高级服务器版所提供的实用功能,可以轻松地完成群集服务器的架设。

  预备知识
  Windows Cluster
  Windows高级服务器版中提供的负载平衡工具,可以为服务器群集中的服务器合理分配任务,并避免因某一台服务器出现问题而导致的服务失败。
  心跳网线
  用于连接服务器群集中两大服务器间的网线,一般在服务器群集中的服务器都配有两块网卡,其中一块专门用于两台服务器(节点)间的通讯,来检测各自的运行状态,一旦某一节点没有了响应则证明该服务器出现了故障,这种侦测的过程被称作“心跳”。
  磁盘阵列
  由一组硬盘组成的磁盘集合,支持热插拔,一般使用SCSI的连接模式,磁盘阵列大多安装在专用的磁盘阵列柜中。
  PERC 2/DC CARD是用于连接存储外围设备的硬件,它内置了可读写的ROM存储器,可以根据用户的需要进行出厂后的二次设置,PERC 2/DC CARD多使用在服务器群集中,用于连接磁盘阵列。

  方案实施1:服务器基本配置
  接下来开始配置服务器:
  1. 给服务器1和服务器2连接网线,其中在两块Realtek Pci Ethernet 10M网卡间连接心跳网线,将Intel Pro 100+ Network Card连接到集线器或交换机上。
  2. 为服务器1安装Windows2000高级服务器版。
  3. 启动服务器1,分别配置服务器上的两块网卡,其中连接心跳网线的使用内部网内的保留IP地址(如:192.168.0.1),另一块网卡使用服务器对外的IP地址。同时把服务器1设置为域控制器。
  4. 为服务器2安装Windows2000高级服务器版,并将服务器2加入到先前服务器1所设置的域中,同样将服务器2的两块网卡分别设置不同的IP地址,注意两台服务器均需要使用同类型的网卡,并且网卡要配置同类的IP地址(例如均为C类地址)。
  在完成以上步骤后,服务器的软硬件设置就基本上完毕了。但是接下来才是群集服务配置中最关键的步骤——配置Windows Cluster!

  方案实施2:配置Windows Cluster
  配置两台服务器的SCSI磁盘
  启动服务器1,但不启动服务器2。如果在服务器群集中使用了外置磁盘阵列,则需要在Windows2000中根据型号的不同升级PERC 2/DC的驱动程序。在使用了RAID磁盘阵列的情况下,用户还必须根据所使用的PERC 2/DC CARD的情况配置它,其配置过程与BIOS的配置有些类似,主要涉及到系统跳线方式、中断模式等参数,它能够与Windows2000高级服务器版的均衡负载服务协同工作。
  进入管理工具中的计算机管理,选择其中的磁盘管理,在这里会显示当前所有使用的磁盘。一般情况下,在首次使用磁盘管理时会显示签名和升级磁盘向导,该向导主要用于提高访问磁盘的安全性。
  服务器群集中的磁盘在进行读写时磁盘必须处于基本状态,用户可以用右键快捷菜单来更改磁盘的状态。
  接下来配置服务器内置的SCSI磁盘,右键单击第一个磁盘,选择创建磁盘。
  确认主分区被选择,并且已启动使用最大磁盘空间选项,为第一个磁盘分配盘符,一般是倒序排列,即第一个磁盘使用盘符Z。
  确认当前磁盘使用NTFS格式,完成配置向导,第一块磁盘开始格式化,重复以上步骤即可完成对多个SCSI磁盘的配置。按照以上步骤也配置服务器2的全部SCSI磁盘,注意服务器2的SCSI磁盘所使用的盘符应与服务器1的不同。
  关闭服务器2,重新启动服务器1,进入计算机管理中的磁盘管理,可以看到除了刚才配置的磁盘,又多出了一些磁盘,根据它们的顺序,分别使用服务器2的盘符更改它们的驱动器名称和路径。关闭服务器1,启动服务器2,并重复上面的步骤,就可以完成两台服务器的SCSI磁盘共享了。在大多数小型机或服务器中,对于SCSI磁盘都提供了主机断电后的多路电源支持,所以在个别服务器断电后,其所使用的SCSI磁盘仍可以被服务器群集中的其他服务器访问到。

  方案实施3:配置服务器的群集服务
  需要注意,两台服务器都必须配置群集服务,才能保证系统的均衡负载,群集服务可以通过安装完成Windows2000高级服务器版后,第一次启动系统REBOOT时弹出的窗口完成的,在配置服务器群集服务时需要保持两台服务器同时启动。
  1.配置服务器1的群集服务
  在启动服务器时,会弹出安装完成的对话框,用户也可以通过管理工具中的配置服务器的安装来完成打开这个窗口。
  在弹出的窗口中,单击“配置”,窗口中会出现一些有关配置服务器的说明,单击“下一步”即可。
  在选择安装节点名称时,为服务器1选择第一个节点。
  输入本服务器群集的名称,在这里一般使用同域相同的名称,例如输入“POPUNET”。
  为域账户设置用户名和密码,这个域与先前设置的域相类似,但添加了管理服务器群集的功能,为了方便起见,一般使用与域控制器相同的用户名和密码。
  点击“下一步”可以进入共享磁盘窗口,可以看到先前设置过的共享磁盘。
  单击“下一步”,选择群集文件存储的目录,注意这些文件要存储在共享磁盘中,一般选择首磁盘Z。
  单击“下一步”,将INTEL PRO 100+ NETWORK CARD网卡配置为连接外部网络,将Realtek PCI Ethernet 10M网卡配置为连接内部网群集。
  在这一步中要为服务器群集配置一个IP地址,注意这个IP地址就是该群集在互联网上的地址,同时将服务器群集的子网掩码设置为255.255.255.0,单击完成,至此即完成了对服务器1的群集配置。
  2.配置服务器2的群集服务。
  服务器2的群集服务配置与服务器1的配置大体相同,这里主要指出它们的不同之处。
  在选择安装节点名称时,使用第二个或者下一个节点。
  服务器2的群集名称应与服务器一所设置的群集名称相同,否则会出现共享磁盘不能互相访问的情况。
  设置域账户时也要使用与服务器1相同的设置。
  到这里,服务器群集的安装就已经基本完成了,接下来就可以根据服务器在网络中发挥的具体功能,分别配置服务器的其他服务了。注意在服务器群集中的服务器在配置其他诸如:WEB、SMTP、NNTP等服务时必须使用相同的设置,不然的话服务器的工作是非常不稳定的。
  方案校验:服务器群集的测试
  如果要检验该方案实施的可行性,可以用非域控制器的服务器中的“群集管理”功能。
  进入“群集管理”界面可以看到当前群集服务器中的全部服务器,其中处于被访问状态的服务器会显示为一个绿色的“UP”字样,分别点击各个服务器,可以对它们的群集服务属性进行设置。同时用户使用群集内的任意一台服务器都可以浏览所有共享磁盘(如图5),关闭任意一台服务器或多台服务器后,再使用其他计算机访问该服务器群集,仍然可以正常访问。证明方案实施成功!

  注意事项
  1.实现服务器群集至少需要两台计算机,分别作为主、从服务器。
  2. 从服务器的硬盘大小必须能够镜像主服务器上所有必要的分区。Windows2000不支持跨越不同硬盘的分区并镜像,所以不能将一个硬盘上的分区镜像到两个较小容量的硬盘上。
  3.至少需要两块用作专用数据链路的Intel PRO/100B网卡。
  4. 专用数据连线(心跳线)可以用五类或超五类双绞线制作。
  5. 专用数据连线的制作方法是将1和2、3和6反接(网卡之间互联时,连接线均为此接法)。
  6. 最好定期备份数据,以防万一。

  服务器群集工作原理
  实施负载平衡的服务器群集中,处理请求被分布于各服务器。负载平衡群集中的各个不同的服务器分担处理负载,但不共享磁盘阵列或内存等资源。如果其中一个服务器发生故障,处理负载可以被简单地重新分布于群集中幸存的各个节点。