数据问题
package Buy.Dao;
import java.sql.Connection;
import java.sql.DriverManager;
import
java.sql.SQLException;
import javax.sql.*;
public class SQLCon {
private static String DRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";
private static String URL="jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=Shop";
private static String NAME="sa";
private static String PWD="";
public static Connection getCon(){
Connection con=null;
try {
Class.forName(DRIVER);
try {
con=DriverManager.getConnection(URL, NAME, PWD);
} catch (
SQLException e) {
e.printStackTrace();
}
} catch (
ClassNotFoundException e) {
e.printStackTrace();
}
return con;
}
}
---------------建立连接class-------
package Buy.Dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import Buy.bean.UseInfo;
public class RegistSql {
Statement st=null;
PreparedStatement pst=null;
UseInfo use=new UseInfo();
Connection con=null;
public boolean Regist(){
boolean flag=false;
con=SQLCon.getCon();
try {
pst=con.prepareStatement("insert into UseInfo (u_name,u_pwd,u_phone,u_address) values (?,?,?,?)");
String u_name=use.getU_name();
String u_pwd=use.getU_pwd();
String u_phone=use.getU_phone();
String u_address=use.getU_address();
pst.setString(1, u_name);
pst.setString(2, u_pwd);
pst.setString(3, u_phone);
pst.setString(4, u_address);
int num=pst.executeUpdate();
flag=true;
} catch (SQLException e) {
e.printStackTrace();
flag=false;
}
return flag;
}
}
请问哪里出错了 也不报异常 数据库字段都是 varchar
------解决方案--------------------顶一楼,还有确认一下sqlserver打到pack3的补丁,数据库要混合登陆方式