Commit 25f064f9 by tzn

Java-Search

parent b8da238d
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
all_books.java
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="com.tushu" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="yunding@localhost" uuid="cf3f84e3-9c53-4bdd-ac29-bcc0bfaa7f65">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306/yunding?useSSL=false&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<component name="libraryTable">
<library name="servlet-api">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../../steam/apache-tomcat-9.0.56/lib/servlet-api.jar!/" />
<root url="jar://$PROJECT_DIR$/../../../steam/apache-tomcat-9.0.56/lib/tomcat-api.jar!/" />
<root url="jar://$PROJECT_DIR$/../../../steam/apache-tomcat-9.0.56/lib/jsp-api.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>com.tushu</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>com.tushu Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
<version>0.0.20131108.vaadin1</version>
<scope>compile</scope>
</dependency>
<!-- JSONObject依赖包 -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.28</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-collections/commons-collections -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.ezmorph/ezmorph -->
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>com.tushu</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
package tushuguanli;
public class Main {
public static void main(String[] args) {
}
}
package tushuguanli.dao;
public class books_data {
private int id;
private int jdid;
private String bookshelf_id;
private String book_name;
private int book_id;
private String category;
private String author;
private String publisher;
private int borrow_times;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getJdid() {
return jdid;
}
public void setJdid(int jdid) {
this.jdid = jdid;
}
public String getBookshelf_id() {
return bookshelf_id;
}
public void setBookshelf_id(String bookshelf_id) {
this.bookshelf_id = bookshelf_id;
}
public String getBook_name() {
return book_name;
}
public void setBook_name(String book_name) {
this.book_name = book_name;
}
public int getBook_id() {
return book_id;
}
public void setBook_id(int book_id) {
this.book_id = book_id;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public int getBorrow_times() {
return borrow_times;
}
public void setBorrow_times(int borrow_times) {
this.borrow_times = borrow_times;
}
}
package tushuguanli.dao;
public class borrow_database {
private int id;
private String username;
private int user_id;
private String book_name;
private int book_id;
private int borrow_time;
private int is_return;
public borrow_database(int id,String username,int user_id,String book_name,int book_id,int borrow_time,int is_return){
this.id=id;
this.username=username;
this.user_id=user_id;
this.book_name=book_name;
this.book_id=book_id;
this.borrow_time=borrow_time;
this.is_return=is_return;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getUser_id() {
return user_id;
}
public void setUser_id(int user_id) {
this.user_id = user_id;
}
public String getBook_name() {
return book_name;
}
public void setBook_name(String book_name) {
this.book_name = book_name;
}
public int getBook_id() {
return book_id;
}
public void setBook_id(int book_id) {
this.book_id = book_id;
}
public int getBorrow_time() {
return borrow_time;
}
public void setBorrow_time(int borrow_time) {
this.borrow_time = borrow_time;
}
public int getIs_return() {
return is_return;
}
public void setIs_return(int is_return) {
this.is_return = is_return;
}
}
package tushuguanli.dao;
public class manage_data {
private int id;
private int manage_account;
private int manage_password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getManage_account() {
return manage_account;
}
public void setManage_account(int manage_account) {
this.manage_account = manage_account;
}
public int getManage_password() {
return manage_password;
}
public void setManage_password(int manage_password) {
this.manage_password = manage_password;
}
}
package tushuguanli.dao;
public class user_data {
private int id;
private int user_account;
private int user_password;
private int student_id;
private int phone_number;
private int overdue_times;
private int havebooks;
public int getHavebooks() {
return havebooks;
}
public void setHavebooks(int havebooks) {
this.havebooks = havebooks;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getUser_account() {
return user_account;
}
public void setUser_account(
int user_account) {
this.user_account = user_account;
}
public int getUser_password() {
return user_password;
}
public void setUser_password(int user_password) {
this.user_password = user_password;
}
public int getStudent_id() {
return student_id;
}
public void setStudent_id(int student_id) {
this.student_id = student_id;
}
public int getPhone_number() {
return phone_number;
}
public void setPhone_number(int phone_number) {
this.phone_number = phone_number;
}
public int getOverdue_times() {
return overdue_times;
}
public void setOverdue_times(int overdue_times) {
this.overdue_times = overdue_times;
}
}
package tushuguanli.survice;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class all_books {
private jdbc JDBC = null;
private Connection conn = null;
public boolean all(){
Statement stmt =null;
String sql="select * from books";
try {
stmt=conn.createStatement();
ResultSet books = stmt.executeQuery(sql);
while(books.next()){
System.out.printf(books.getString("id"));
System.out.printf(books.getString("book_name"));
System.out.printf(books.getString("author"));
System.out.printf(books.getString("category"));
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}finally {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}return true;
}
}
package tushuguanli.survice;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
public class book_massage {
private jdbc JDBC = null;
private Connection conn = null;
public boolean messang(){
Statement pstmt=null;
Scanner bookname =new Scanner(System.in);
String sql="SELECT id,jdid,bookshelf_id,book_name,book_id,category,author,publisher,borrow_times; FROM user WHERE book_name=bookname";
try {
pstmt=conn.createStatement();
ResultSet books = pstmt.executeQuery(sql);
ResultSet rs = pstmt.executeQuery(sql);
while(rs.next()){
int id = rs.getInt("id");
int jdid = rs.getInt("jdid");
int book_id = rs.getInt("book_id");
int bookshelf_id = rs.getInt("bookshelf_id");
String book_name = rs.getString("book_name");
String category = rs.getString("category");
String author = rs.getString("author");
String publisher = rs.getString("publisher");
int borrow_times = rs.getInt("borrow_times");
System.out.print("ID: " + id);
System.out.print(", jdid: " + jdid);
System.out.print(", book_id: " + book_id);
System.out.print(", bookshelf_id: " + bookshelf_id);
System.out.print(", book_name: " + book_name);
System.out.print(", category: " + category);
System.out.print(", author: " + author);
System.out.print(", publisher: " + publisher);
System.out.println(", borrow_times: " + borrow_times);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}finally {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}return true;
}
}
package tushuguanli.survice;
import java.util.Scanner;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class borrow {
private jdbc JDBC = null;
private Connection conn = null;
public boolean borrow_books() {
Statement pstmt = null;
Scanner intput_name = new Scanner(System.in);
String sql = "select name from user where name=input_name";
try {
pstmt = conn.createStatement();
ResultSet user = pstmt.executeQuery(sql);
ResultSet rs = pstmt.executeQuery(sql);
int id = rs.getInt("id");
int student_id = rs.getInt("student_id");
int overdue_times = rs.getInt("overdue_times");
int havebooks = rs.getInt("havebooks");
if (havebooks>=3){
System.out.println("您现在已借的书的数目大于3本");
}else {
System.out.print("ID: " + id);
System.out.print(", student_id: " + student_id);
System.out.print(", overdue_times: " + overdue_times);
System.out.print(", havebooks: " + havebooks);
System.out.println("选择设否同意借书:1、同意。2、不同意");
Scanner scanner=new Scanner(System.in);
int result=scanner.nextInt();
if(result == 1){
sql = "replce into borrow(username,book_name,borrow_time)";
}else
{
System.out.println("很遗憾,您没有借到书");
}
}
} catch (SQLException throwables) {
throwables.printStackTrace();
} finally {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
return true;
}
}
}
\ No newline at end of file
package tushuguanli.survice;
import java.sql.Statement;
import java.util.Scanner;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public class daohang {
private jdbc JDBC = null;
private Connection conn = null;
public boolean search(){
Statement pstmt=null;
Scanner inputcategory =new Scanner(System.in);
String sql="SELECT id,jdid,bookshelf_id,book_name,book_id,category,author,publisher,borrow_times; FROM user WHERE (inputcategory=category";
try {
pstmt=conn.createStatement();
ResultSet books = pstmt.executeQuery(sql);
ResultSet rs = pstmt.executeQuery(sql);
while(rs.next()){
int id = rs.getInt("id");
int jdid = rs.getInt("jdid");
int book_id = rs.getInt("book_id");
int bookshelf_id = rs.getInt("bookshelf_id");
String book_name = rs.getString("book_name");
String category = rs.getString("category");
String author = rs.getString("author");
String publisher = rs.getString("publisher");
int borrow_times = rs.getInt("borrow_times");
System.out.print("ID: " + id);
System.out.print(", jdid: " + jdid);
System.out.print(", book_id: " + book_id);
System.out.print(", bookshelf_id: " + bookshelf_id);
System.out.print(", book_name: " + book_name);
System.out.print(", category: " + category);
System.out.print(", author: " + author);
System.out.print(", publisher: " + publisher);
System.out.println(", borrow_times: " + borrow_times);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}finally {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}return true;
}
}
package tushuguanli.survice;
import java.util.Scanner;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class give_back{
private jdbc JDBC = null;
private Connection conn = null;
public boolean give_books() {
Statement pstmt = null;
System.out.println("是否同意还书:1、同意。2、不同意。");
Scanner intput_name = new Scanner(System.in);
String sql = "select name from user where name=input_name";
try {
pstmt = conn.createStatement();
ResultSet user = pstmt.executeQuery(sql);
ResultSet rs = pstmt.executeQuery(sql);
int id = rs.getInt("id");
int student_id = rs.getInt("student_id");
int overdue_times = rs.getInt("overdue_times");
int havebooks = rs.getInt("havebooks");
if (havebooks>=3){
System.out.println("您现在已借的书的数目大于3本");
}else {
System.out.print("ID: " + id);
System.out.print(", student_id: " + student_id);
System.out.print(", overdue_times: " + overdue_times);
System.out.print(", havebooks: " + havebooks);
System.out.println("选择设否同意借书:1、同意。2、不同意");
Scanner scanner=new Scanner(System.in);
int result=scanner.nextInt();
if(result == 1){
sql = "replce into borrow(username,book_name,borrow_time)";
}else
{
System.out.println("很遗憾,您没有借到书");
}
}
} catch (SQLException throwables) {
throwables.printStackTrace();
} finally {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
return true;
}
}
}
\ No newline at end of file
package tushuguanli.survice;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.*;
public class jdbc {
//数据库连接 MySQL:8.0.14
public class DBConnection {
public static final String DRIVER = "com.mysql.cj.jdbc.Driver";
public static final String URL = "jdbc:mysql://localhost:3306/yunding?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true";
public static final String USER = "root";
public static final String PASSWORD = "123456";
Connection conn = null;
public DBConnection() {
try {
Class.forName(DRIVER);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
conn = DriverManager.getConnection(URL, USER, PASSWORD);
} catch (SQLException e) {
e.printStackTrace();
}
}
public Connection getConnection() {
return this.conn;
}
public void close() {
if (this.conn != null) {
try {
this.conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
package tushuguanli.survice;
import tushuguanli.survice.jdbc;
import java.util.Scanner;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class search {
private jdbc JDBC = null;
private Connection conn = null;
public boolean search() throws SQLException {
Statement pstmt=null;
Scanner scanner = new Scanner(System.in);
int select=scanner.nextInt();
String sql;
if(select==1){
Scanner bookname =new Scanner(System.in);
sql="select * from books where book_name like `%bookname%`";
}else{
Scanner scanner1 =new Scanner(System.in);
String zuozhe=scanner1.next();
sql="select * from books where author like `%zuozhe%`";
}
ResultSet rs = pstmt.executeQuery(sql);
try {
while(rs.next()){
int id = rs.getInt("id");
int jdid = rs.getInt("jdid");
int book_id = rs.getInt("book_id");
int bookshelf_id = rs.getInt("bookshelf_id");
String book_name = rs.getString("book_name");
String category = rs.getString("category");
String author = rs.getString("author");
String publisher = rs.getString("publisher");
int borrow_times = rs.getInt("borrow_times");
System.out.print("ID: " + id);
System.out.print(", jdid: " + jdid);
System.out.print(", book_id: " + book_id);
System.out.print(", bookshelf_id: " + bookshelf_id);
System.out.print(", book_name: " + book_name);
System.out.print(", category: " + category);
System.out.print(", author: " + author);
System.out.print(", publisher: " + publisher);
System.out.println(", borrow_times: " + borrow_times);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}finally {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}return true;
}
}
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment