I don't know why i am getting this error infact i write code write and also add java connector in my project. Please any one resolve my issue
import java.sql.*;
public class jbdcdemo {
public static void main(String[] args) {
try{
//1. Get Connection to DB
Connection myConn = DriverManager.getConnection("jbdc:msql://localhost:3306/world","root","1234");
//2. Create a statement
Statement myStmt = myConn.createStatement();
//3. Execute sql query
ResultSet myRs = myStmt.executeQuery("SELECT * FROM world.city;");
//4. Process the results
while(myRs.next()){
System.out.println(myRs.getString("Name")+", "+myRs.getString("District"));
}
}
catch(Exception exc){
exc.printStackTrace();
}
}
}
Try fixing the connection string:
Connection myConn = DriverManager.getConnection(" jdbc : mysql ://localhost:3306/world","root","1234")
Looks like you have semicolon for the sql statement,
Below is the correct one.
ResultSet myRs = myStmt.executeQuery("SELECT * FROM world.city");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.