包含java亮剑的词条

博主:adminadmin 2023-01-18 09:03:07 249

今天给各位分享java亮剑的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

关于java方面的有事请教………

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

/**

* @author lufei_200x

*

* 数据库名为 mytest,用户名和密码定为root,root

* 数据表为 user_info (

* username[字符型,主键],

* password[字符型,非空]

* )

* 本人用mysql做测试数据库,已经换成sql2008的方式

* 但要自己去下载java连接sql2008的驱动,一搜就有

*/

public class UserInformation {

Connection conn = null;

Statement stmt = null;

ResultSet rs = null;

PreparedStatement pstmt = null;

// 注册一个用户

public void insert(String userName, String userPassword, Connection conn) {

try {

String sql = "INSERT INTO USER_INFO VALUES(?,?)";

pstmt = conn.prepareStatement(sql);

pstmt.setString(1, userName);

pstmt.setString(2, userPassword);

pstmt.executeUpdate();

System.out.println("插入数据成功!");

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

System.out.println("插入数据失败!");

}

}

// 验证用户名密码的非空,合格返回true

public boolean checkUser(String userName, String userPassword){

if(userName==null||"".equals(userName)||userPassword==null||"".equals(userPassword)){

System.out.println("用户名或密码为空!");

return false;

}

return true;

}

// 判断此用户名是否存在

public boolean isExist(String userName, Connection conn) {

try {

String sql = "SELECT USERNAME,PASSWORD FROM USER_INFO WHERE USERNAME='"+userName+"'";

stmt = conn.createStatement();

rs = stmt.executeQuery(sql);

// 用户名重复

if(rs.next()){

System.out.println("用户名重复!");

return true;

}

} catch (SQLException e) {

e.printStackTrace();

}

return false;

}

// 连接sql2008数据库

public Connection connect() {

try {

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")

//Class.forName("com.mysql.jdbc.Driver")

.newInstance();

// 连接路径,数据库名称为 mytest

String url = "jdbc:sqlserver://localhost:1433;DatabaseName=mytest";

// String url = "jdbc:mysql://localhost:3306/mytest";

// 连接数据库的用户名和密码均为root,这个你自己建数据库酌情更改

String user = "root";

String password = "root";

conn = DriverManager.getConnection(url, user, password);

System.out.println("数据库连接成功!");

} catch (Exception e) {

e.printStackTrace();

System.out.println("数据库连接失败!");

conn = null;

}

return conn;

}

为什么亮剑java web开发案例都跑不了,而且录视频的人操作太2了,一直反复操作一点也不熟练

那个开发案例需要自己来配置数据库,还有添加jar包,这本书很坑的

亮剑跑腿外卖源码是什么

亮剑跑腿外卖源码是由Java搭建的。外卖跑腿系统解决了全套的方案,单独的指派订单或者众包模式,软件分为商家端,配送端,用户端,强大的后台调度管理功能。跑腿外卖系统自动派单是由平台通过系统获取骑手精确位置,进行订单调度计算,筛选出最适合配送当前订单的骑手,自动完成订单指派。

求一道java作业题

下面是我写的代码,分两个类写的。

①Book.java

public class Book {

private String bookname;

private String author;

private int sales;

public Book() {

this.bookname = "";

this.author = "";

this.sales = 0;

}

public Book(String bookname, String author, int sales) {

this.bookname = bookname;

this.author = author;

this.sales = sales;

}

public void setBook(String bookname, String author, int sales) {

this.bookname = bookname;

this.author = author;

this.sales = sales;

}

public void printBook() {

System.out.print(this.bookname);

System.out.print("\t");

System.out.print("\t");

System.out.print(this.author);

System.out.print("\t");

System.out.print("\t");

System.out.println(this.sales);

}

}

②TestBook.java

public class TestBook {

public static void main(String[] args) {

Book b1 = new Book();

Book b2 = new Book();

Book b3 = new Book();

Book b4 = new Book();

Book b5 = new Book("万古神帝", "飞天鱼", 342);

Book b6 = new Book("阴阳师", "小墨鱼", 470);

Book b7 = new Book("斗罗大陆", "唐家三少", 207);

Book b8 = new Book("完美世界", "辰东", 214);

Book b9 = new Book("亮剑", "都梁", 78);

b1.setBook("天龙八部", "金庸", 150);

b2.setBook("盗墓笔记", "南派三叔", 420);

b3.setBook("元尊", "天蚕土豆", 368);

b4.setBook("都灵", "红色警戒", 42);

System.out.print("书名");

System.out.print("\t");

System.out.print("\t");

System.out.print("作者");

System.out.print("\t");

System.out.print("\t");

System.out.println("月销售量");

b1.printBook();

b2.printBook();

b3.printBook();

b4.printBook();

b5.printBook();

b6.printBook();

b7.printBook();

b8.printBook();

b9.printBook();

}

}

下面是我做的测试结果的截图,麻烦帮忙看一下,是否能够符合要求。

java亮剑的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、java亮剑的信息别忘了在本站进行查找喔。