SQL Serverk 用户自己建立的Systop 数据库属于什么

SQL Serverk 用户自己建立的Systop 数据库属于什么,第1张

请按照下列步骤 *** 作:

1、打开K/3安装目录下的K3ERP文件夹,并找到DBFILE文件夹;

2、右键单击DBFILE文件夹,依次单击【安全】→【添加】→【高级】,单击【立即查找】,选中everyone用户

3、依次单击【确定】,并且允许“完全控制权限”,单击【确定】即可。

,具体点可以这样:创建一个用户表,里边包括LoginName(登录名),UserName(用户名),Password(密码),Age(年龄),Address(地址)。然后编写Java程序(用MVC架构)模型层(M):DBConnection.java(负责连接数据库)

import java.sql.Connection

import java.sql.DriverManager

import java.sql.*

public class DBConnection {

private static final String DRIVER_CLASS = "sun.jdbc.odbc.JdbcOdbcDriver"

private static final String DB_URL = "jdbc:odbc:text"

public DBConnection() {

}

public static Connection getConnection() {

Connection conn = null

try {

Class.forName(DRIVER_CLASS)

conn = DriverManager.getConnection(DB_URL)

} catch (SQLException ex) {

System.out.println(ex.getMessage())

} catch (ClassNotFoundException ex) {

System.out.println(ex.getMessage())

}

return conn

}

}

第2个负责数据库查询 *** 作的类:DBUserManager.java

import edu.systop.text.model.entity.User

import edu.systop.text.model.dao.DBConnection

import java.sql.Connection

import java.sql.PreparedStatement

import java.sql.ResultSet

import java.sql.DriverManager

import java.sql.*

public class DBUserManager {

private static final String SQL_SELECT =

"SELECT LoginName,UserName,PassWord,Age,Address FROM UserInfo WHERE LoginName = ? AND PassWord = ?"

public DBUserManager() {

}

public boolean checkDB(User u) {

boolean b = false

Connection conn = null

PreparedStatement psmt = null

ResultSet rs = null

conn = DBConnection.getConnection()

try {

psmt = conn.prepareStatement(SQL_SELECT)

psmt.setString(1, u.getLoginName())

psmt.setString(2, u.getPassWord())

rs = psmt.executeQuery()

b = rs.next()

if (rs.next()) {

b = true

}

} catch (SQLException ex) {

System.out.println(ex.getMessage())

} finally {

cleanDB(rs, psmt, conn)

}

return b

}

public User checkBC(User u) {

Connection conn = null

PreparedStatement psmt = null

ResultSet rs = null

User tmp = new User()

conn = DBConnection.getConnection()

try {

psmt = conn.prepareStatement(SQL_SELECT)

psmt.setString(1, u.getLoginName())

psmt.setString(2, u.getPassWord())

rs = psmt.executeQuery()

if (rs.next()) {

tmp.setLoginName(rs.getString(1))

tmp.setUserName(rs.getString(2))

tmp.setAge(rs.getInt(4))

tmp.setAddress(rs.getString(5))

}

} catch (SQLException ex) {

System.out.println(ex.getMessage())

} finally {

cleanDB(rs, psmt, conn)

}

return tmp

}

public void cleanDB(ResultSet rs, PreparedStatement psmt, Connection conn) {

try {

if (rs != null) {

rs.close()

}

if (psmt != null) {

psmt.close()

}

if (conn != null) {

conn.close()

}

} catch (SQLException ex) {

System.out.println(ex.getMessage())

}

}

第3个实体用户类:User.java

package edu.systop.text.model.entity

public class User {

private String loginName

private String userName

private String passWord

private int age

private String address

public User() {

}

public void setLoginName(String loginName) {

this.loginName = loginName

}

public void setUserName(String userName) {

this.userName = userName

}

public void setPassWord(String passWord) {

this.passWord = passWord

}

public void setAge(int age) {

this.age = age

}

public void setAddress(String address) {

this.address = address

}

public String getLoginName() {

return loginName

}

public String getUserName() {

return userName

}

public String getPassWord() {

return passWord

}

public int getAge() {

return age

}

public String getAddress() {

return address

}

}

然后编写控制层(C):GetInfoServlet.java

package edu.systop.text.control

import javax.servlet.*

import javax.servlet.http.*

import java.io.*

import java.util.*

import edu.systop.text.model.entity.User

import edu.systop.text.model.service.UserManager

public class GetInfoServlet extends HttpServlet {

private static final String CONTENT_TYPE = "text/htmlcharset=GBK"

//Initialize global variables

public void init() throws ServletException {

}

//Process the HTTP Get request

public void doGet(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

}

//Process the HTTP Post request

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

String loginName = request.getParameter("loginName")

String passWord = request.getParameter("passWord")

User u = new User()

u.setLoginName(loginName)

u.setPassWord(passWord)

UserManager m = new UserManager()

RequestDispatcher d

if (m.checkUser(u)) {

User o = m.checkBC(u)

request.setAttribute("JavaBEAN",o)

d = request.getRequestDispatcher("GetInfoUser.jsp")

} else {

d = request.getRequestDispatcher("GetInfoFinale.jsp")

}

d.forward(request, response)

}

//Clean up resources

public void destroy() {

}

}

最后,创建表示层(V):包括3个Jsp(登录页面GetInfo.jsp、登录成功页面GetInfoUser.jsp、登录失败页面GetInfoFinale.jsp)

上面的就是Jsp结合Servlet用MVC架构写的用户登录程序。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9943534.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-03
下一篇 2023-05-03

发表评论

登录后才能评论

评论列表(0条)

保存