java 学习之路第一节

  • 时间:
  • 浏览:0
  • 来源:大发快3计划—大发一分彩

// 连接MySql数据库,用户名和密码时会root

import java.sql.SQLException;

}

二、看数据库中哪些表安装:navicat for MySQL

public static final String url = "jdbc:mysql://192.168.1000.42:310006/jobhunter_test";

import java.sql.Connection;

}

Statement stmt = con.createStatement();

一、安装mysql驱动: http://mvnrepository.com/search?q=mysql-conn

ResultSet re = stmt.executeQuery(query);

import java.sql.Statement;

public static final String password = "test";

e.printStackTrace();

se.printStackTrace();

// 3.创建另1个 Statement

try {

}

文件类写数据库查询:

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

public static final String username = "test";

System.out.println("找不可以驱动守护程序运行运行类 ,加载驱动失败!");

} catch (SQLException se) {

public class baseServer {

System.out.println(re.getString("userId"));

import java.sql.ResultSet;

// 1.加载MySql的驱动类

try {

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

public static void main(String[] args) {

} catch (ClassNotFoundException e) {

Connection con = DriverManager.getConnection(url, username, password);

while (re.next()) {

import java.sql.DriverManager;

}

// 2.获取数据库链接

}

String query = "select * from online ";

package hunteronHC;