- 浏览: 428756 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
weishuang:
全部无法访问
ArcGIS 资源 -
04023129:
请问一下怎么配置meetme有硬件要求么?
Asterks(软交换)里配置两部简单的SIP软电话 -
jayli426:
请教:
181 正被转接
202 被接受:用于转介
有 ...
所有已知的SIP处理应答状态码 -
ligg5034:
<ww:if test="sftd.equal ...
webwork<ww:if>标签的使用 -
wanggod:
请问我
return (Hello)super.getPort ...
java6 WebServices客户端
连接池
添加以下引用
System.EnterpriseServices
System.Runtime.Remoting
using System;
using System.IO;
using System.Text;
using System.Reflection;
using System.Runtime.InteropServices;
using System.EnterpriseServices;
[assembly: ApplicationName("POOLINGTEST")]
[assembly: AssemblyKeyFile("poolserver.snk")]
namespace PoolServer
{
[ObjectPooling(Enabled=true,MinPoolSize=0, MaxPoolSize=1,CreationTimeout=2000)]
[JustInTimeActivation(true)]
[ConstructionEnabled(Default="Workstation id=.;data source=.;initial catalog=card;integrated security=sspi")] //Text File to be created during construction
public class PooledFile : ServicedComponent
{
private string strConnection;
protected override void Construct(string constructString)
{
strConnection = constructString;
}
public string ConnectionString
{
get
{
return strConnection;
}
}
}
}
远程数据库访问类
添加以下引用
System.EnterpriseServices
System.Runtime.Remoting
添加连接池组件PoolServer.dll
using System;
using PoolServer;
using System.Reflection;
using System.Data;
using System.Data.SqlClient;
namespace RemoteTest
{
//SQL Server数据库连接类
public class SQLConnection:MarshalByRefObject
{
private SqlConnection m_sqlConn;
private SqlDataAdapter m_sqlDA;
private SqlCommand m_sqlComm;
public SQLConnection()
{
PooledFile pool = new PooledFile();
m_sqlConn = new SqlConnection(pool.ConnectionString);
}
//创建一个SQLConnection连接实例
public SQLConnection(string strConnection)
{
Console.WriteLine("有数构造");
m_sqlConn = new SqlConnection(strConnection);
}
//执行查询,返回DataSet对象(多条记录)
public DataSet executeQueryDS(string strQuery,string table)
{
open();
m_sqlDA = new SqlDataAdapter(strQuery, m_sqlConn);
DataSet ds = new DataSet();
m_sqlDA.Fill(ds,table);
close();
return ds;
}
//执行查询,返回SqlDataReader对象(一条记录)
//执行该方法后,必须执行close()方法以关闭SQL Server数据库连接
public SqlDataReader executeQueryDR(string strQuery)
{
open();
m_sqlComm = new SqlCommand(strQuery, m_sqlConn);
SqlDataReader dr;
dr = m_sqlComm.ExecuteReader();
return dr;
}
//执行更新,返回所影响的行数
public int executeUpdate(string strUpdate)
{
open();
m_sqlComm = new SqlCommand(strUpdate, m_sqlConn);
int rows;
rows = m_sqlComm.ExecuteNonQuery();
return rows;
}
public bool isExistProcudure(string sql, SqlParameter[] param)
{
m_sqlComm = new SqlCommand(sql, m_sqlConn);
m_sqlComm.CommandType = CommandType.StoredProcedure;
if (param != null)
{
foreach (SqlParameter parameter in param)
{
m_sqlComm.Parameters.Add(parameter);
}
}
open();
int n = Convert.ToInt32(m_sqlComm.ExecuteScalar());
close();
if (n >= 0)
{
return true;
}
else
{
return false;
}
}
//执行返回查询结果的存储过程
public SqlDataReader executeQueryProcedure(string strCommandText, SqlParameter[] param)
{
open();
m_sqlComm = new SqlCommand(strCommandText, m_sqlConn);
m_sqlComm.CommandType = CommandType.StoredProcedure;
if (param != null)
{
foreach (SqlParameter parameter in param)
{
if(parameter != null)
{
m_sqlComm.Parameters.Add(parameter);
}
}
}
SqlDataReader dr = m_sqlComm.ExecuteReader();
return dr;
}
//执行更新,返回所影响行数的存储过程
public int executeUpdateProcedure(string strCommandText, SqlParameter[] param)
{
open();
m_sqlComm = new SqlCommand(strCommandText, m_sqlConn);
m_sqlComm.CommandType = CommandType.StoredProcedure;
if (param != null)
{
foreach (SqlParameter parameter in param)
{
if(parameter != null)
{
m_sqlComm.Parameters.Add(parameter);
}
}
}
int rows = m_sqlComm.ExecuteNonQuery();
return rows;
}
//打开SQLConnection连接
public void open()
{
if(m_sqlConn.State == ConnectionState.Closed)
{
m_sqlConn.Open();
}
}
//关闭SQLConnection连接
public void close()
{
if(m_sqlConn.State == ConnectionState.Open)
{
m_sqlConn.Close();
}
}
}
}
服务器
添加以下引用System.EnterpriseServices
System.Runtime.Remoting
添加数据库访问类组件RemoteTest.dll
private SQLConnection obj;
private bool m_bSign=true;
private void sign()
{
TcpServerChannel channel = new TcpServerChannel(9932);
obj = new SQLConnection();
ChannelServices.RegisterChannel(channel);
ObjRef objref=RemotingServices.Marshal(obj, "TestLoader", typeof(SQLConnection));
}
private void btn_start_Click(object sender, System.EventArgs e)
{
//RemotingConfiguration.RegisterWellKnownServiceType(typeof(SQLConnection),
// "TestLoader", WellKnownObjectMode.Singleton );
if(m_bSign)
{
m_bSign=false;
this.sign();
}
else
{
ObjRef objrefWellKnown = RemotingServices.Marshal(obj, "TestLoader");
}
this.lb_message.Items.Clear();
this.lb_message.Items.Add("CM+服务器已起动!!!");
this.btn_start.Enabled=false;
this.btn_stop.Enabled=true;
}
private void btn_stop_Click(object sender, System.EventArgs e)
{
this.btn_stop.Enabled=false;
this.btn_start.Enabled=true;
RemotingServices.Disconnect(obj);
//ChannelServices.UnregisterChannel(channel);
this.lb_message.Items.Add("COM+服务器已关闭!!!");
}
private void menuItem_openServer_Click(object sender, System.EventArgs e)
{
if(m_bShowWnd==true)
{
this.Visible=true;
m_bShowWnd=false;
}
}
private void menuItem_minimize_Click(object sender, System.EventArgs e)
{
if(m_bShowWnd==false)
{
this.Visible=false;
m_bShowWnd=true;
}
}
private void menuItem_exit_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show("你确定要退出COM+服务器吗?如果单击是,它将终止所有访问数据库的服务.","信息提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if(result==DialogResult.Yes)
{
this.Close();
}
}
private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{
m_bShowWnd=false;
this.Visible=true;
}
private void button1_Click(object sender, System.EventArgs e)
{
menuItem_exit_Click(null,null);
}
private void label2_Click(object sender, System.EventArgs e)
{
if(m_bShowWnd==false)
{
this.Visible=false;
m_bShowWnd=true;
}
}
客户端
添加以下引用
System.EnterpriseServices
System.Runtime.Remoting
添加数据库访问类组件RemoteTest.dll
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using RemoteTest;
using System.Data.SqlClient;
namespace Client
{
public class ClassClient
{
static void Main(string[] args)
{
try
{
ChannelServices.RegisterChannel(new TcpClientChannel());
SQLConnection loader=(SQLConnection)Activator.GetObject(typeof(SQLConnection),"tcp://localhost:9932/TestLoader");
if(loader==null)
{
Console.WriteLine("Unable to get remote");
}
else
{
SqlParameter[] param=new SqlParameter[2];
param[0] = new SqlParameter("@emp_id", SqlDbType.NChar, 9); //存储过程的输入参数
param[0].Value = "PMA42628M";
param[1] = new SqlParameter("@emp_name", SqlDbType.NVarChar, 20); //存储过程的输出参数
param[1].Direction = ParameterDirection.Output;
ESqlParameter[] eparam = new ESqlParameter[2];
eparam[0] = new ESqlParameter(param[0]);
eparam[1] = new ESqlParameter(param[1]);
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream("MyFile.txt", FileMode.Create, FileAccess.Write, FileShare.None, 1000, true);
formatter.Serialize(stream, eparam);
//执行根据指定员工编号查询员工名字的存储过程
SqlDataReader dr =loader .executeQueryProcedure("prcGetEmpName", stream);
stream.Close();
stream = null;
GC.Collect();
System.Console.WriteLine("员工编号 : " + param[0].Value);
System.Console.WriteLine("员工名字 : " + param[1].Value);
conn.close();
}
catch(SingletonException err)
{
System.Console.WriteLine(err.Message);
}
catch(Exception err)
{
System.Console.WriteLine(err.ToString());
}
}
[Serializable]
public class ESqlParameter
{
public ESqlParameter(SqlParameter sPara)
{
this.paraName = sPara.ParameterName ;
this.paraLen = sPara.Size ;
this.paraVal = sPara.Value ;
this.sqlDbType= sPara.SqlDbType ;
}
public SqlParameter ToSqlParameter()
{
SqlParameter para = new SqlParameter(this.paraName ,this.sqlDbType ,this.paraLen) ;
para.Value = this.paraVal ;
return para ;
}
private string paraName = "" ;
public string ParaName
{
get
{
return this.paraName ;
}
set
{
this.paraName = value ;
}
}
private int paraLen = 0 ;
public int ParaLen
{
get
{
return this.paraLen ;
}
set
{
this.paraLen = value ;
}
}
private object paraVal = null ;
public object ParaVal
{
get
{
return this.paraVal ;
}
set
{
this.paraVal = value ;
}
}
private SqlDbType sqlDbType = SqlDbType.NVarChar ;
public SqlDbType SqlDbType
{
get
{
return this.sqlDbType ;
}
set
{
this.sqlDbType = value ;
}
}
}
一步:打开管理工具,打开服务,然后把所有关于COM+的服务起动
二步:起动Distributed Transaction Coordinator服务
三步:注册强名称
1.打开.net命令窗口
2.定位COM+所在目标,然后输入 sn -k 强名称
二步:起动服务器
三步:客房端访问
发表评论
-
Visual studio 2010无法安装Silverlight4 Tools的解决办法
2011-02-28 12:05 2194如果你也碰到这个问题,那么算你运气好;昨日下了园子里vs2 ... -
C# winform32位加密算法
2008-06-19 15:07 1387private string MD5(string sourc ... -
.net下的SHA-1与MD5加密算法
2008-06-19 15:07 2007//SHA-1算法string password = Syst ... -
用C#写的自定义数据库操作类
2008-06-19 15:06 1748using System;using System.Data; ... -
数据库、服务器设置
2008-06-19 15:05 972private ConnClass.SqlConn sql; ... -
起泡排序与简单排序法
2008-06-19 15:03 972using System; namespace 排序算法{cl ... -
顺序查找与二分查找
2008-06-19 15:02 1184using System; namespace 查找算法{cl ... -
正则表达式应用范例
2008-06-19 15:02 888The following example shows the ... -
序列化与反序列化
2008-06-19 15:01 1271poorServer 代码 using System ... -
获取本机和远程计算机IP及MAC地址
2008-06-19 15:00 4737利用dns类和WMI规范获取I ... -
DataList里面用C#实现自定义分页
2008-06-19 14:59 1706PagedDataSource pds=new Pa ... -
ASP.NET里面用C#实现发送邮件
2008-06-19 14:59 1884if(TextBoxNumber1.Text==" ... -
如何控制DataGrid里的内容换行与不换行
2008-06-19 14:58 1874<FONT size=2><%@ Page ... -
在C#窗体应用程序中载入Web页
2008-06-19 14:57 4607用AxWebBrowser的准备 "工具箱&quo ... -
VS2005[C#] 操作 Excel 2003
2008-06-19 14:56 2557using System;using System.Colle ... -
VS C# 2008里只让应用程序只运行一个实例
2008-06-19 14:55 1505using System;using System.Colle ... -
VS C# 2008导入到Excel 2007
2008-06-19 14:54 2621string path = System.Environmen ... -
VS C# 2008导入到xml
2008-06-19 14:53 1269//创建MobileBackup.xml文件 ... -
VS C# 2008从xml里读取数据
2008-06-19 14:53 1236//从xml文件中读取发件箱信息 private ... -
VS C# 2008鼠标移上时与按下时动态改变PicturBox的背景图片
2008-06-19 14:52 1591//获得当前项目运行的路径 path ...
相关推荐
基于tp5的swoole支持,对th5的connection进行改造,使用Swoole\Coroutine\MySQL重写了基于swoole的PDO接口,实现了mysql的数据库连接池,本地测试可用。使用时,替换thinkphp/library/think/db/Connection.php,并...
Delphi编写的 COM+组件实现客户端、服务器回调 delphi实现的COM+组件处理数据库Blob字段 Delphi实现的com+组件数据库连接池
第六部分 调试与部署COM和COM+应用程序 第18章 调试与剖析COM和COM+应用程序 调试VB组件 调试MTS组件 调试COM+组件 使用条件编译 调试VC++组件 用VisualStUdioAnalyzer剖析 小结 第19章 部署COM与...
java毕设, 技术栈 - 数据库:MySQL 5.7.33 ...- 数据连接池:Druid - 前端技术:Layui,Ajax,Json等 - Web容器:Apache Tomcat 8 - 项目管理工具:Maven 3.6.0 - 版本控制工具:Git - 开发工具:IDEA
环境配置(Tomcat与JDK的版本使用问题,DBCP/C3P0数据库连接池的配置问题) 2. 登录(会话)维持————session/cookies 3. 分页显示————PageModel/jdbc-mysql查 ### 实现图 ![主页]...
4. 数据库连接池 druid ### 2.3 前端技术栈 1. html 2. css 3. jquery 4. bootstrap 5. thymeleaf ## 三 软件运行 1.安装 IDEA,maven,mysql及客户端工具 2.使用idea打开项目,配置jdk 和 maven 3.创建数据库,并...
12.3.4 COM+对象池 12.4 COM+新增系统服务 12.4.1 COM+队列组件 12.4.2 COM+事件模型 12.4.3 负载平衡 12.3.4 内存数据库 小结 第13章 COM+应用开发 13.1 最简单的COM+组件——例程Step1 13.1.1 创建一个最...
使用Request,Response,session存储数据),`JDBC`(德鲁伊数据库连接池,使用QueryRunner处理数据) 和上一次系统[bootstrap+JavaEE+JDBC+JSP的信息管理系统](https://gitee.com/LovelyHzz/Info-management-system...
” target=”_self”>sqlserver2008配置数据库连接池 具体步骤: 1、在server.xml中设置数据源,以sql server 2008数据库为例,如下: 在<GlobalNamingResources> 节点中加入, <Resource name=jdbc/...
这个项目比较简单,界面使用的swing,主要也就用到JDBC的相关技术,用到了连接池技术dbcp,数据的增删改查都写在了Dao层,由于项目比较小,并没有一个表对应一个Dao,都写在一个Dao里,比较方便像一些insert(String...
* 数据库连接池 * 单例对象 */ public class DBConnectionManager { static private DBConnectionManager instance; // 唯一实例 static private int clients; private Vector<Driver> drivers = new Vector...
数据库连接池配置 <br>环境:xp2+IE7.0+tomcat5.028+mysql5.018 <br>1.假定tomcat 安装目录为:D:\Tomcat5 <br>2.假定程序目录为: D:\web\WebRoot <br> 目录设置请看WebRoot.xml 中有下面这句代码:...
本项目采用当前主流的MVC和IOC框架spring 3、优秀的ORM框架hibernate和超级厉害的proxool数据库连接池。这个工程demo,是本人在企业应用中的项目缩影,绝对实用于企业的应用。 适合朋友: 1.一直用单独的servlet和...
Python + Postgresql + PostGIS爬虫获取某地图POI数据 (1)网络爬虫 (2)多线程 (3)数据库连接池
采用 Spring + SpringMVC + MyBatisPlus,连接池采用 Druid,安全框架使用 Shiro,前端采用 Bootstrap + layer 实现。 支付采用支付宝沙箱环境,支付APP下载链接,[点击这里]...
并使用 Ehcache 作为项目的缓存,druid 作为项目的数据库连接池,使用 FreeMarker 实现 word 的导出,使用 Shiro 完成项目的登录认证,数据库使用的则是 MySQL。 该系统可以分为三类角色:学生,教师,教务管理员。...
数据库连接池:Alibaba Druid 1.0 缓存框架:Ehcache 2.6 + Redis 2.9.0 日志管理:SLF4J 1.7 + Log4j2 2.7 布局框架:SiteMesh 3.0.1 分布式应用程序协调服务:ZooKeeper 3.3.1 分布式服务框架:Dubbo 2.5.3 接口...
没积分的同学看这里免费下载地址 : http://blog.java1234.com/download.html ...数据库连接池使用的是阿里巴巴的 Druid; 在线编辑器使用了百度的 UEditor,支持单图,多图上传,支持截图上传,支持代码高亮特性;