先建好工程,添加jar包(去官网下载,或者在虚拟机hive/lib目录下下载)
mysql-connect-java-5.1.38.jar
如果是maven工程,只需要在pom.xml文件里添加
<plugin>
<artifactId>mysql-connect-java</artifactId>
<version>5.1.38</version>
</plugin>
接下来就是代码了
object mysqlConnectScala {
private val driver="com.mysql.jdbc"
private val url="jdbc:mysql://192.168.158.10:3306/Scala"
private val username="root"
private val password