📄 test.java
字号:
package test;
import java.util.*;
import javax.naming.*;
/* 引入两个客户端包:
* C:\jboss-4.2.1.GA\client下的:jnp-client.jar和jbossall-client.jar
*/
public class Test {
public static void main(String[] args) {
try {
Properties p = new Properties();
p.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");;
p.setProperty("java.naming.provider.url", "jnp://localhost:1099");
p.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
Context ctx = new InitialContext(p);
Object ref= ctx.lookup("StuinfoFacade/remote");
StuinfoFacadeRemote remote=(StuinfoFacadeRemote)ref;
Stuinfo xie=remote.findById(1);
System.out.println("姓名:"+xie.getStuName() );
System.out.println("**********添加*******************");
/* Stuinfo stu=new Stuinfo();
stu.setStuId(100);
stu.setStuName("谢天谢地");
stu.setStuSex("男");
stu.setStuAddress("kkkk");
stu.setStuAge(20);
remote.save(stu); */
System.out.println("**********添加ok*******************");
System.out.println("所有学生:"+remote.findAll().size() );
List list= remote.findPage(2, 5);
System.out.println("第二页大小:"+list.size() );
Stuinfo kk= remote.getScoresByStuId(1);
Set s= kk.getScoreses();
for(Object o:s)
{
Scores score=(Scores)o;
System.out.println("成绩ID="+score.getScoresId()+" java="+score.getJava());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -