In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.