DB-Connection

Henri

Benutzer
Beiträge
16
Hallo Leute,

was mache ich denn falsch?
Code:
import java.sql.Connection;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.DriverManager;



public class App {

    public static void main(String[] args) throws ClassNotFoundException {
        
        // Connect to database
        String hostName = "xxxxxxxxx"; // update me
        String dbName = "DMT"; // update me
        String user = "sa"; // update me
        String password = "46,00fas75"; // update me
        String url = "jdbc:mysql://" + hostName + "/" + dbName + "/" + user + "/" + password;
        Connection connection = null;
        

        try {
            connection = DriverManager.getConnection(url);
            String schema = connection.getSchema();
            System.out.println("Successful connection - Schema: " + schema);

            System.out.println("Query data example:");
            System.out.println("=========================================");

            // Create and execute a SELECT SQL statement.
            String selectSql = "SELECT [Projektnummer]FROM [dbo].[Boards]";

            try (Statement statement = connection.createStatement();
            ResultSet resultSet = statement.executeQuery(selectSql)) {

                // Print results from select statement
                System.out.println("Projektnummer");
                while (resultSet.next())
                {
                    System.out.println(resultSet.getString(1) + " "
                        + resultSet.getString(2));
                }
                connection.close();
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}


ich bekomme den folgenden Fehler

java.sql.SQLException: No suitable driver found for jdbc:mysql://xxxxxxxx/DMT/sa/46,00fas75
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at crossword.App.main(App.java:28)
 
Werbung:
Werbung:
Zurück
Oben