JDBC connection mysql database

xiaoxiao2021-03-06  61

Step1: Find driver

MySQL currently provides the Java driver for Connection / J, you can download from the mysql official website, and find the mysql-connector-java-3.0.15-ga-bin.jar file, this driver is a pure Java driver, no need to do Other configurations.

Step2: Dynamic Specify ClassPath

If you need to perform the ClassPath when you need to execute, use the -cp mode when executed. Otherwise add the above .jar file to the ClassPath environment variable.

Step3: Load driver

Try {class.Forname ("com.mysql.jdbc.driver); system.out.println (" Success Loading MySQL DRIVER!);} catch (exception e) {system.out.println ("Error Loading MySQL Driver ! "); E.PrintStackTrace ();} Step4: Set the connected URL

JDBC: mysql: // localhost / databasename [? PA = VA] [& pa = va]

转载请注明原文地址:https://www.9cbs.com/read-111510.html

New Post(0)