太棒了,我逐渐理解一切
This commit is contained in:
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
||||
@@ -0,0 +1,33 @@
|
||||
import java.sql.*;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.sql.*;
|
||||
import com.mysql.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/game", "root", sc.next());
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery("SELECT * FROM player;");
|
||||
while (resultSet.next()) {
|
||||
System.out.println("id:\t" + resultSet.getInt("id"));
|
||||
System.out.println("name:\t" + resultSet.getString("name"));
|
||||
System.out.println("sex:\t" + resultSet.getString("sex"));
|
||||
System.out.println("email:\t" + resultSet.getString("email"));
|
||||
System.out.println("level:\t" + resultSet.getInt("level"));
|
||||
System.out.println("exp:\t" + resultSet.getInt("exp"));
|
||||
System.out.println("gold:\t" + resultSet.getDouble("gold"));
|
||||
System.out.println("------------------------------------------------");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user