选择显示字体大小

转贴-jbuilder7+weblogic7存取sql server2000

jbuilder7的配置:

1. 修改环境变量temp和tmp 为不带空格的目录如:e:\winnt\temp

2. 启动jbuilder7,选择:tools->configure servers

3. 选中左侧的weblogic application server 6.x+,选中右边的enable server

4. 将general->home directory设为weblogic7的home directory如:e:/bea/weblogic700/server,正常的话jbuilder7将自动为你添好其他的项。

5. 将custom->jdk installation directory设为 jdk的安装目录,如:e:/bea/jdk131_02

6. 将custom->bea home directory设为weblogic7的home director,如:e:/bea

7. 将custom->domain directory设为你的域目录,如:e:/bea/user_projects/mydomain

8. 添好user name, password ,domain name, server name后,单击ok退出。

9. 选择:tools->enterprise setup,单击corba页上的new, 按下表填写相应信息:

name for this configuration = wellogic 7.0

path for orb tools = e:/bea/weblogic700/server

library for projects = weblogic 6.x+ deploy

idl compiler command = idlj.exe

commnad option for output directory = e:\corbaoutput(任意目录,不要有空格)

单击ok退出。

10.选择project->default project properties

在path页的required libraries中将会看到weblogic 6.x+ client和weblogic 6.x+ deploy两项,如果没有,请检查以上步骤是否正确。

11.选择server页,单击single services for all service in project

在下拉列表中选择weblogic application server 6.x+,但击ok退出,配置完毕。



weblogic7的配置:

1. 启动weblogic7

2. 打开ie6,在地址栏中输入:http://localhost:7001/console

3. 输入用户名和密码

4. 在左边的目录树中选中services->jdbc->connection pools,单击右侧的configure a new jdbc connection pool.,输入以下信息:

configuration->general页:

name = sql server connection pool

url = jdbc:weblogic:mssqlserver4:northwind@localhost

driver classname = weblogic.jdbc.mssqlserver4.driver

properties : user = sa

password = &ldquo;&rdquo; <- sa的密码

单击create建立连接池。

targets->server页:

将myserver(服务器名称)移至右侧的列表中,但击单击apply

5. 在左边的目录树中选中services->jdbc->data sources(或者txdata sources),单击右侧的configure a new jdbc connection pool.,输入以下信息:

configuration->general页:

name = sqlserver tx data source

jndi name = sqlserver

pool name = sql server connection pool

选中emulate two-phase commit for non-xa driver和row prefetch enabled

单击create建立数据源。

targets->server页:

将myserver(服务器名称)移至右侧的列表中,但击单击apply,配置完毕。

实战1:连接sqlserver2000
1. 打开jbuilder7选择file->new project

在name栏中输入sqlserverdemo,directory栏中输入存放路径(不要有空格),其他不变,单击finish。

2. 选择file->new,选择general->application,单击ok。

第一步,第二步和第三步都不用更改,直接finish即可。

3. 回到jbuilder7的集成开发环境中,单击右侧的designer页设计窗体,在窗体中放入一个jscrollpane 和jtextarea 及三个按钮,双击第一个按钮输入以下代码:

try

{

class.forname(&quot;weblogic.jdbc.mssqlserver4.driver&quot;);

connection con = drivermanager.getconnection(&quot;jdbc:weblogic:mssqlserver4:northwind@localhost&quot;,&quot;sa&quot;,&quot;&quot;);//此处根据你的sqlserver帐户而定。

statement st = con.createstatement();

resultset res = st.executequery(&quot;select * from employees&quot;);

string line = &quot;&quot;;

while (res.next())

line = line + res.getstring(&quot;title&quot;)+&quot;\n&quot;;

jtextarea1.settext(line);

con.close();

}

catch (exception ex)

{

jtextarea1.settext(&quot;error : &quot;+ex.getmessage());

}

双击第二个按钮输入以下代码

hashtable ht = new hashtable();

ht.put(context.initial_context_factory,&quot;weblogic.jndi.wlinitialcontextfactory&quot;);

ht.put(context.provider_url,&quot;t3://localhost:7001&quot;);



try

{

context ctx = new initialcontext(ht);

datasource ds = (datasource)ctx.lookup(&quot;sqlserver&quot;);

connection con = ds.getconnection(&quot;system&quot;,&quot;12345678&quot;);//此处是weblogic7

的域用户和密码

statement st = con.createstatement();

resultset res = st.executequery(&quot;select * from employees&quot;);

string line = &quot;&quot;;

while (res.next())

line = line + res.getstring(&quot;notes&quot;)+&quot;\n&quot;;

jtextarea1.settext(line);

con.close();

}

catch (exception ex)

{

jtextarea1.settext(&quot;error : &quot;+ex.getmessage());

}

运行weblogic7,运行程序单击第一个按钮使用jdbc直接连接sqlserver并获取数据,单击第二个按钮使用datasource连接sqlserver并获取数据。

实战2:session bean
建立一个简单的bean:

1. 关闭所有工程:file->close projects

2. 选择file->new project

在name栏中输入hellodemo,directory栏中输入存放路径(不要有空格),其他不变,单击finish。

3. 选择file->new->enterprise->ejb 2.0 designer单击ok。

在弹出的对话框中单击new建立一个moudle,在name中输入hellomoudle单击ok关闭当前对话框,再次单击ok关闭对话框。

4. 在右侧的工作区中单击右键选择:create ejb->session bean,将bean name改为hellobean

5. 右键单击代表hellobean的长方形,选择add->method

按如下填写:

method name = sayhello

return type = java.lang.string

input parameter 不添

interface = remote

6. 右键单击代表hellobean的长方形,选择 view bean source

按如下填写sayhello():

public java.lang.string sayhello()

{

/**@todo complete this method*/

return new string(&ldquo;hello world &ldquo;);

}

7.按f9运行,在弹出的对话框中选择run页,单击new,在configure name处填写server runtime configuration,再选择run->server,单击ok关闭当前对话框,单击ok开始编译运行。运行起来之后在左上角的目录树中右键单击hellomodule选择:deploy options for &ldquo;hellomodule.jar&rdquo;->deploy来发布bean。

建立客户端:

1. 选择file->new->enterprise->ejb test client单击ok。

选中genrate method for 特斯廷remote interface calls with default arguments单击ok。

2. 按如下填写main():

public static void main(string[] args)

{

hellobeantestclient1 client = new hellobeantestclient1();

// use the client object to call one of the home interface wrappers

// above, to create a remote interface reference to the bean.

// if the return value is of the remote interface type, you can use it

// to access the remote interface methods. you can also just use the

// client object to call the remote interface wrappers.

client.create();

system.out.println(client.sayhello());

} 选择run->run &ldquo;hellobeantestclient1.java&rdquo; using defaults运行。


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons