📄 artistclient.java
字号:
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.ejb.*;
import java.sql.*;
public class ArtistClient
{
private String iArtist_code,cArtist_name,cArea;
ArtistHome home;
Artist remote;
public String getiArtist_code()
{
return iArtist_code;
}
public String getcArtist_name()
{
return cArtist_name;
}
public String getcArea()
{
return cArea;
}
public void setiArtist_code(String iArtist_code)
{
this.iArtist_code=iArtist_code;
}
public void setcArtist_name(String cArtist_name)
{
this.cArtist_name=cArtist_name;
}
public void setcArea(String cArea)
{
this.cArea=cArea;
}
public ArtistClient()throws SQLException
{
try
{
Context init=new InitialContext();
Object obj=init.lookup("Artist");
home=(ArtistHome)PortableRemoteObject.narrow(obj,ArtistHome.class);
}
catch(Exception e)
{
throw new SQLException(e.toString());
}
}
public String createEvent()throws SQLException
{
String Message="";
try
{
remote=home.create( iArtist_code,cArtist_name,cArea);
Message="the Artist has created";
}
catch(DuplicateKeyException dupex)
{
Message="the code"+iArtist_code+"has been in the DataBase";
System.out.println(dupex.toString());
}
catch(Exception e)
{
System.out.println(e.toString());
}
return Message;
}
public String updateEvent()
{
String Message="";
try
{
remote=home.findByPrimaryKey(iArtist_code);
remote.update(iArtist_code,cArtist_name,cArea);
Message="Successful!";
}
catch(Exception e)
{
Message="Modify Failed";
System.out.println(e.toString());
}
return Message;
}
public String deleteEvent()
{
String Message="";
try
{
remote=home.findByPrimaryKey(iArtist_code);
remote.remove();
Message="Delete Successful";
}
catch(Exception e)
{
Message="Cannot find the code";
System.out.println(e.toString());
}
return Message;
}
public Vector findEvent()
{
String Message="";
Vector v=new Vector();
try
{
remote=home.findByPrimaryKey(iArtist_code);
String st=remote.getArtistcode();
String str=remote.getArtistname();
String stri=remote.getArtistarea();
v.addElement(st);
v.addElement(str);
v.addElement(stri);
Message="Result by searching ID";
}
catch(Exception e)
{
Message="invalid ID,please check your ID";
System.out.println(e.toString());
}
return v;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -