Battle JBUILDER7 WebLogic7 Access MS SQL Server2000 (1)
Liu Xiaowei: Liuxiaowei2000@sina.com
For the first time, I hope everyone will hold a lot. This article is completely written according to my personal experience. If there is any mistake, please ask you to correct!
JBuilder7 WebLogic7 configuration
Suppose JBuilder7 and WebLogic7 are installed, the operating system is: Windows2000 Server (SP2), the database is: SQLServer2000 (SP2).
JBUILDER7 configuration:
1. Modify environment variables TEMP and TMP for directorys without spaces such as: E: / WinNT / TEMP
2. Start JBuilder7, choose: Tools-> Configure Servers
3. Select the WebLogic Application Server 6.x on the left, select the enable server on the right.
4. Set General-> Home Directory to WebLogic7 Home Directory, such as: E: / BEA / WebLogic700 / Server, normal JBuilder7 will automatically add other items to you.
5. Set the Custom-> JDK Installation Directory as the JDK installation directory, such as: E: / BEA / JDK131_02
6. Set the Custom-> Bea Home Directory to WebLogic7 home director, such as: E: / BEA
7. Set Custom-> Domain Directory as your domain directory, such as: E: / bea / user_projects / mydomain
8. Add User Name, Password, Domain Name, Server Name, click OK to exit.
9. Select: Tools-> Enterprise Setup, click New on the CORBA page, follow the table to fill in the appropriate information:
Name for this configuration = Wellogic 7.0
Path for orb Tools = E: / bea / WebLogic700 / Server
Library for processing = WebLogic 6.x Deploy
IDL Compiler Command = idlj.exe
Commnad option for output directory = E: / corbaoutput (any directory, do not have spaces)
Click OK to exit.
10. Choose Project-> Default Project Properties
WEBLOGIC 6.X Client and WebLogic 6.x deploy in the Required Libraries in the PATH page are not, please check if the above steps are correct.
11. Select Server page, click Single Services for All Service in Project
Select WebLogic Application Server 6.x in the drop-down list, but strike OK exit, configure it.
WebLogic7 configuration:
1. Start WebLogic7
2. Open IE6 and enter: http: // localhost: 7001 / console3. Enter your username and password
4. Select Services-> JDBC-> Connection Pools in the directory tree on the left, click the Configure a new JDBC Connection Pool on the right. You enter the following information:
Configuration-> General Page:
Name = SQL Server Connection Pool
URL = JDBC: WebLogic: MSSQLSERVER4: Northwind @ localhost
Driver classname = WebLogic.jdbc.msqlserVer4.driver
Properties: User = SA
Password = "" <- SA password
Click Create to establish a connection pool.
Targets-> Server Page:
Move your MyServer to the list of the right, but click Apply
5. Select Services-> JDBC-> Data Sources-> JDBC-> Data Sources-> JDBC-> Data Source, click on the CONFIGURE A NEW JDBC Connection Pool on the right. Enter the following information:
Configuration-> General Page:
Name = SQLSERVER TX DATA SOURCE
JNDI Name = SQLServer
Pool Name = SQL Server Connection Pool
Select Emulate TWO-PHASE COMMIT for Non-Xa Driver and Row Prefetch Enabled
Click Create to establish a data source.
Targets-> Server Page:
Move myServer to the list of the right, but click Apply, the configuration is complete.
Practical 1: Connect SQLServer2000
1. Open JBuilder7 Select File-> New Project
Enter SQLSERVERDEMO in the Name column, enter the storage path in the Directory column (do not have spaces), other unchanged, click Finish.
2. Select File-> New, select General-> Application, click OK.
The first step, the second step and third steps do not have to be changed, directly finish.
3. Go back to the JBuilder7 integrated development environment, click the Designer page design form on the right, put a JScrollPane and Jtextarea and three buttons in the form, double-click the first button to enter the following code:
Try
{
Class.Forname ("WebLogic.jdbc.mssqlserVer4.driver");
Connection con = DriverManager.getConnection ("JDBC: WebLogic: MSSQLServer4: Northwind @ localhost", "sa", ""); // is based on your SQLServer account.
Statement ST = con.createstatement ();
ResultSet Res = St.executeQuery ("Select * from Employees);
String line = "";
While (res.next ())
LINE = line res. maxString ("Title") "/ n";
Jtextarea1.settext (line);
C. close ();
}
Catch (Exception EX)
{
Jtextarea1.settext ("Error:" ex.getMessage ());
}
Double-click the second button to enter the following code
Hashtable ht = new hashtable ();
HT.PUT (Context.Initial_Context_Factory, "WebLogic.jndi.wlinitialContextFactory";
HT.PUT (Context.Provider_URL, "T3: // localhost: 7001");
Try
{
Context CTX = New InitialContext (HT);
DataSource DS = (Datasource) CTX.lookup ("SQLServer");
Connection con = ds.getConnection ("System", "12345678"); // This is WebLogic7
Domain users and passwords
Statement ST = con.createstatement ();
ResultSet Res = St.executeQuery ("Select * from Employees);
String line = "";
While (res.next ())
LINE = line res. maxString ("notes") "/ n";
Jtextarea1.settext (line);
C. close ();
}
Catch (Exception EX)
{
Jtextarea1.settext ("Error:" ex.getMessage ());
}
Run WebLogic7, run the program Click the first button to connect SQL Server directly using JDBC and get data, click the second button to connect SQL Server with DataSource and get data.
Practical 2: session bean
Practical 3: Entity Bean
(to be continued)