Get the App
SLTechnology News&Howtos  ›  Database  › 

How to access java language and how to quickly build mysql

Shulou Source: shulou.com Published: 2022-05-31 21:33:31 09月28日 Update

This article focuses on "how to access mysql rapid construction of java language", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to access mysql rapid construction with java language".

Environment:

? Operating system: RedHat linux 7.1

Mysql Server: 3.23.36 (included with linux 7.1)

? mysql jdbc: 2.0.14

? java JDK: j2sdk-1.4.0_02

Get the jdbc of mysql:

Mysql-connector-java-2.0.14.tar.gz

? Download address:

? 1. HKLPG/Hong Kong

? 2.ihostunit.com/Hong Kong

? 3. Shellhung.org/Hong Kong

Get j2sdk:

J2sdk-1.4.0_02 of java.sun.com

Install mysql jdbc:

Shell > tar-zxpf mysql-connector-java-2.0.14.tar.gz

? Installing j2sdk is not covered here.

Set up the CLASSPATH:

Shell > CLASSPATH=$CLASSPATH:/ your mysql-jdbc driver directory

? / mysql-connector-java-2.0.14-bin.jar

Shell > export CLASSPATH

Establish a connection in java:

Class.forName (com.mysql.jdbc.Driver) .newInstance ()

Connection conn=DriverManager.getConnection

? ("jdbc:mysql://localhost/test?user=root&password=")

Test:

? Premise: your CLASSPATH must be correct and javac and java will work properly.

Shell > cd / directory of your mysql-jdbc driver / testsuite

Shell > java DateTest

? If the screen prompts:

About to insert date 1017684000000

Inserted row 1

Selected date from row 1: 1017684000808

1974-01-01

1974-01-01

? That is, everything is fine.

Exception:

? The screen prompt "Server configuration denies access to data source" when running DateTest

Solution:

? First enter mysql and log in as root, then enter the following.

Mysql > GRANT ALL PRIVILEGES ON [dbname]. * to'[user] @'[hostname]'

? Identified by'[password]'

? (note: here replace dbname with your database name, in DateTest, test; will replace user with your user name, the author's is root; will replace hostname with the machine where the java program is running, the author is running on this machine, that is, 'localhost'; replace password with your mysql user's password, the author does not have a password, that is'. )

Mysql > FLUSH PRIVILEGES

At this point, I believe you have a deeper understanding of "how to access mysql rapid construction of java language". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Run language access content program author password screen method user directory driver learning prompt driver practical deeper operating system interest premise Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker Xiaomi Apple macOS