我的博客我做主

我的未来不是梦!
posts - 9, comments - 10, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

2010年8月7日

感谢大家都我博客的关注和关系,现在将博客迁移到www.v5cn.cn上面了,有兴趣的童鞋可以到上面寻找自己感兴趣的技术博文,主要包括WorldWind,Lucene等技术。www.v5cn.cn

posted @ 2013-10-08 14:02 平常心 阅读(137) | 评论 (0)编辑 收藏

更多博客请查看:http://www.v5cn.cn
在安装好Sql Server2005后默认是不支持JTA分布式事务的,要进行一下额外的设置才可以支持JTA事务。
那么如何让Sql Server2005具有JTA事务那,那大家就跟我一步一步做吧!
第一步:
    下载Sql Server2005的JDBC驱动。下载完成后得到的是一个exe文件:“sqljdbc_1.0.809.102_chs.exe”。
    双击打开:
    
    点击Browse... 选择要解压的目录。解压后得到:
    
    其中:sqljdbc.jar是Java连接Sql Server2005的驱动程序。
    打开xa目录:
    
    可以看到x64目录和x86目录和xa_install.sql文件
    我们这里选择x86也就是32位的机器。打开可以看到sqljdbc_xa.dll文件
    复制该文件到Sql Server2005的安装目录中的Binn文件夹下面。(Sql Server2005的安装目录下面有很多Binn,我也不知道那个复制那个不复制,所以我就都复制了。
    有知道的朋友可以回复告诉大家和我!)
第二步:
    打开操作系统win7和XP:
        win7下面是:控制面板--> 系统和安全-->管理工具-->组件服务-->计算机-->Distributed Transaction Coordinator-->右键,【本地DTC】,【属性】选择【安全】勾选
        启用XA事务,点击确认。服务会重启。
        XP:控制面板-->管理工具-->组件服务-->计算机-->我的电脑-->右键,【属性】如图:
        
        
        勾选【启用XA事务】点击确定完成。
第三步:
    复制xa_install.sql到Sql Server2005的查询分析器中执行会创建一个角色:sqlJDBCXAUser
    因为Sql Server2005默认的超级管理员sa无法绑定sqlJDBCXAUser,所以我们重新创建一个超级管理员名称dba
    然后把sqlJDBCXAUser授权给他就可以了:
    1. 创建用户和授权:
        a). 创建用户:
            
            b). 登录名的基本配置:
                
                
                
    点击确认用户创建成功!重启数据库服务。
    使用刚创建的用户登录。使用JTA分布式事务时也使用该用户登录,就OK了!

posted @ 2010-10-15 15:16 平常心 阅读(2374) | 评论 (0)编辑 收藏

更多博客请查看:http://www.v5cn.cn
1.创建一个Web工程,添加Struts2支持。
2.创建两个实体类:
a). Mother(母亲)的Java类。
package struts.map.entity;

import java.io.Serializable;

public class Mother implements Serializable {

private static final long serialVersionUID = 1L;

private int motherId;        //母亲ID
    private String motherName;        //母亲名字
    public int getMotherId() {
return motherId;
}
public void setMotherId(int motherId) {
this.motherId = motherId;
}
public String getMotherName() {
return motherName;
}
public void setMotherName(String motherName) {
this.motherName = motherName;
}
}

b).Children(孩子)的Java类

package struts.map.entity;

import java.io.Serializable;

public class Children implements Serializable {

private static final long serialVersionUID = 1L;

private int childId;        //孩子ID
    private int motherId;        //母亲的ID
    private String childName;        //孩子名字
    
public int getChildId() {
return childId;
}
public void setChildId(int childId) {
this.childId = childId;
}
public int getMotherId() {
return motherId;
}
public void setMotherId(int motherId) {
this.motherId = motherId;
}
public String getChildName() {
return childName;
}
public void setChildName(String childName) {
this.childName = childName;
}
}

 

3. 创建一个Action,并创建一位母亲和她的孩子。

package struts.map.test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import struts.map.entity.Children;
import struts.map.entity.Mother;

import com.opensymphony.xwork2.ActionSupport;

public class Struts2_Map extends ActionSupport {

private static final long serialVersionUID = 1L;

private Map<Mother,List<Children>> motherChildn;

public Map<Mother, List<Children>> getMotherChildn() {
return motherChildn;
}

@Override
public String execute() throws Exception {
/*-------------------以对象做父节点的键,List做子节点的值,的Map-----------------------*/
Mother mother 
= new Mother();
mother.setMotherId(
10000);
mother.setMotherName(
"花木兰");

Children children1 
= new Children();
children1.setChildId(
10000);
children1.setMotherId(
10000);
children1.setChildName(
"小花木兰1");

Children children2 
= new Children();
children2.setChildId(
10001);
children2.setMotherId(
10000);
children2.setChildName(
"小花木兰2");

Children children3 
= new Children();
children3.setChildId(
10002);
children3.setMotherId(
10000);
children3.setChildName(
"小花木兰3");

motherChildn 
= new HashMap<Mother,List<Children>>();

List
<Children> childrens = new ArrayList<Children>();

childrens.add(children1);
childrens.add(children2);
childrens.add(children3);

motherChildn.put(mother,childrens);

return SUCCESS;
}
}

struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="map" extends="struts-default">
<action name="struts_map" class="struts.map.test.Struts2_Map">
<result>result.jsp</result>
</action>
</package>
</struts>  

4.创建两个页面:
a).跳转页面:
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>Struts_Map</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>

<body>
<href="struts_map.action">查看Map</a>
</body>
</html>

b).最终页面,也是作重要的页面:
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>Struts_Map</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>

<body>
<div>
<h3>-----------------以对象做父节点的键,List做子节点的值,的Map--------------------</h3>
<s:iterator var="mc" value="motherChildn">
<div>
母亲名称:
<s:property value="key.motherName"/>
</div>
<s:iterator var="ch" value="value">
<div>
&nbsp;&nbsp;&nbsp;孩子名称:<s:property value="#ch.childName"/>
</div>
</s:iterator>
</s:iterator>
</div>
</body>
</html>

最终运行结果:

posted @ 2010-08-26 22:18 平常心 阅读(6865) | 评论 (0)编辑 收藏

更多博客请查看:http://www.v5cn.cn
第一步:下载安装的文件
    1. MySQL:下载地址mysql-5.1.49-win32.msi
2. Apache: 下载地址httpd-2.2.16-win32-x86-openssl-0.9.8o.msi
3. PHP5.3.3  下载地址php-5.3.3-Win32-VC6-x86        注意:一定要下载php-5.3.3-Win32-VC6-x86版本
的,不要下载php-5.3.3-nts-Win32-VC6-x86版本,更不要下载VC9版本的,因为他是IIS服务器安装版本。
 第二步:安装文件
1. 在要安装的磁盘建一个文件夹(笔者的做法是在D盘的根目录下创建一个php文件夹D:\php)。
2. 安装Apache服务器,安装完成后的目录结果是:D:\php\Apache。
3. 把下载的php-5.3.3-Win32-VC6-x86解压的D:\php目录中,可以把文件夹的名字改短,结果D:\php\php5
4. 安装MySql数据库,它的安装和一般情况一样。笔者把他安装在(D:\php\MySQL)和php同目录。
第三步:配置PHP5.3.3
    1. 配置PHP5.3.3,打开php安装目录(笔者是D:\php\php5)可以看到目录下有两个这样的文件php.ini-    development和php.ini-production,第一个是开发使用的配置文件,第二个是标准的生产环境的配置。
2. 选择php.ini-development复制一份到同目录下,并改名为php.ini使用文本工具打开,查找extension_dir,可以
看到两个,选择On windows:下面的那个并去得前面的分号修改为extension_dir = "D:/php/php5/ext",读者根
据自己的目录结构配置,目的是找到和php.ini同目录下的ext文件夹中的扩展库。
3. 查找extension=php_,去掉extension=php_curl.dll、extension=php_gd2.dll、extension=php_mbstring.dll、
extension=php_mysql.dll、extension=php_mysqli.dll、extension=php_pdo_mysql.dll、extension=php_xmlrpc.dll
前面
的分号。查找short_open_tag = Off把它修改成short_open_tag = On,让其支持短标签。
4. 复制php5ts.dll文件到WINDOWS/system32目录下,只有php-5.3.3-Win32-VC6-x86版本中才有php5ts.dll 
        php-5.3.3-nts-Win32-VC6-x86版本是没有的。
第四步:配置Apache
1. 打开Apache目录下conf目录中的
httpd.conf文件,查找#LoadModule,在其末尾处大概是128行的地方
添加:
 LoadModule php5_module "D:/php/php5/php5apache2_2.dll"
PHPIniDir "D:/php/php5"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .html

目录结构根据用户自己目录配置。
2. 查找DirectoryIndex index.html 将其修改成DirectoryIndex index.php default.php index.html index.htm default.html 
default.htm
    3. 查找DocumentRoot将其修改为指向你需要放置web文件的文件夹上(笔者在D:/php目录中创建了一个
www文件夹)所以DocumentRoot就是DocumentRoot "D:/php/www",读者可以根据自己配置来修改。
4. 查找<Directory将其修改为你自己配置的DocumentRoot的路径(笔者是<Directory "D:/php/www">)
第五步:测试php+Apache+MySql是否配置成功
1. 打开MySql在MySql中创建一个新数据库和表。(笔者是userInfo数据库和users表就有id和name两个字段)
测试吗?简单就好,呵呵!!
2. 在上面创建的www文件夹中创建一个index.php文件使用EditPlus或者其他文本工具打开。
3. 写入:
<?
    
$DB_HOST = "localhost";
    
$DB_USER = "root";
    
$DB_PASS = "root";
    
$DB_NAME = "userInfo";

    
mysql_connect($DB_HOST,$DB_USER,$DB_PASS);
    
mysql_select_db($DB_NAME);
    
    
mysql_query("set NAMES gb2312");
    
$sql = "Select * From users";
    
$result = mysql_query($sql);
    
while($data=mysql_fetch_array($result)){
        
echo "------------------------";
        
echo $data['id']."<br/>";
        
echo $data['name']."<br/>";
    }
    
mysql_close();
?>
4.启动Apache服务器,在浏览器输入http://localhost/回车。
如果看到下图:表示我们大功告成了!祝贺祝贺!

posted @ 2010-08-07 12:13 平常心 阅读(8098) | 评论 (6)编辑 收藏