LoginPassward class:package user.login;
public class LoginPassword{
public LoginPassword(){}
static char[] digits = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z' };
static public String genPassword(){
int temp;
String password = "";
for( int i=0; i<8; i++ ){
temp = ( new Double( Math.random() * 997 ) )
.intValue() % 36;
password += String.valueOf( digits[ temp ] );
}
return password;
}
}
public class LoginPassword{
public LoginPassword(){}
static char[] digits = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z' };
static public String genPassword(){
int temp;
String password = "";
for( int i=0; i<8; i++ ){
temp = ( new Double( Math.random() * 997 ) )
.intValue() % 36;
password += String.valueOf( digits[ temp ] );
}
return password;
}
}
解决方案 »
- spring3.0整合Hibernate3.6的问题
- 整合S2SH的时候Tomcat启动报的错。
- 从一个 大文本文件(大概100多MB) 快速查找一个字符串。查找时间最好在1秒以内。
- struts iterate 嵌套迭代问题,急,在线等~
- 为什么这个代码会抛出异常????
- 初学习hibernat遇到的问题
- 关于启动注解配置 在什么情况下要使用
- 初学Hibernate,有一点疑惑。
- 配置Weblogic中JDBC Pool的出错信息,大家帮我看看:
- too much points shared with friends!
- 如何将字符串中的空格替换为其他符号?
- 能不能給我一個JDBC for SQL server的驅動呀?免費的而且比較好用的。
import user.ejb.*;
import java.util.*;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.rmi.PortableRemoteObject;
import javax.ejb.*;
import java.sql.*;public class UserData{ private String id=null;
private String password=null;
private String name=null;
private String age;
private String telephone;
private String address;
UserHome userhome=null; public UserData() throws SQLException{
try{
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(h);
Object homeObject = ctx.lookup("userRemote");
userhome=(UserHome)PortableRemoteObject.narrow(homeObject,UserHome.class);
}catch(Exception ex){
ex.printStackTrace();
throw new SQLException(ex.toString());
}
} public void updateUser() throws SQLException{
try{
User user=userhome.findByPrimaryKey(id);
}catch(Exception ex){
throw new
SQLException("載蜊囮啖!");
}
} public void insertUser() throws SQLException{
try{
User user=userhome.create(id, name, age, telephone, address);
this.password=user.getPassword();
}catch(DuplicateKeyException dupkeyex){
throw new
SQLException("id : "+id+"眒湔婓");
}catch(CreateException ex){
throw new
SQLException("id : "+id+"陔崝囮啖!");
}catch(Exception ex){
}
} public void deleteUser() throws SQLException{
try{
User user=userhome.findByPrimaryKey(id);
user.remove();
}catch(Exception ex){
throw new
SQLException("刉壺囮啖!");
}
} public boolean isMember() throws Exception{
try{
User user=userhome.findByPrimaryKey(id);
if(user.getPassword().equals(password)){
name=user.getName();
age=user.getAge();
telephone=user.getTelephone();
address=user.getAddress();
return true;
}
}catch(ObjectNotFoundException notfoundex){
return false;
}catch(Exception ex){
throw ex;
}
return false;
} public void setId(String id){
this.id=id;
}
public String getId(){
return this.id;
}
public void setPassword(String password){
this.password=password;
}
public String getPassword(){
return this.password;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
public void setAge(String age){
this.age=age;
}
public String getAge(){
return this.age;
}
public void setTelephone(String telephone){
this.telephone=telephone;
}
public String getTelephone(){
return this.telephone;
}
public void setAddress(String address){
this.address=address;
}
public String getAddress(){
return this.address;
}
}
是不是错了,适宜是ps.execute();
也应该是可以的~~只是ps.execute();
还多执行任何的SQL(如SELECT)密码生成应该没有问题的,不知道你的TABLE中的PASSWORD是不是允许NULL我想是应该允许
不然会有SQLException的(废话~~)恩~~怎么不调试一下?
关注中~~!!@!@
錯誤如下:
java.rmi.RemoteException:EJB Exception:;nested exception is:
javax.ejb.EJBException:ejbCreate exception:null
急死了,快快幫忙, 搞定就結貼.
JBuilder生成EJB时会自动生成一个TEST的Methods,
发布完了试验一下是否成功了
TEST 也是一樣的錯誤.
getConnection()中
是这样的
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.23.39:1521:sorder","test","test");注意你的con对象是新创建的,并不是你的全局con所以你的全局con是null...
所以你在调用con.get****异常
所以是null异常