Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未找到适用于dbc的驱动程序:mysql://localhost:8080/kholofedb_Java_Mysql_Sql_Jdbc_Mysql Connector - Fatal编程技术网

Java 未找到适用于dbc的驱动程序:mysql://localhost:8080/kholofedb

Java 未找到适用于dbc的驱动程序:mysql://localhost:8080/kholofedb,java,mysql,sql,jdbc,mysql-connector,Java,Mysql,Sql,Jdbc,Mysql Connector,我在网上搜索了整个昨天的这个问题。。。我是JDBC的初学者,但这里提供的解决方案和其他网站对我来说并不适用 我正在Linux Mint 32位上使用“mysql-connector-java-5.1.18-bin.jar”。。我正在使用Eclipse3.8…我已经安装了mySQL服务器,并且它正在运行(我使用:sudo服务mySQL start)运行它。。。在运行时,我得到了这个错误 connecting to psysical database... java.sql.SQLExcepti

我在网上搜索了整个昨天的这个问题。。。我是JDBC的初学者,但这里提供的解决方案和其他网站对我来说并不适用

我正在Linux Mint 32位上使用“
mysql-connector-java-5.1.18-bin.jar
”。。我正在使用Eclipse3.8…我已经安装了mySQL服务器,并且它正在运行(我使用:
sudo服务mySQL start
)运行它。。。在运行时,我得到了这个错误

connecting to psysical database...


java.sql.SQLException: No suitable driver found for dbc:mysql://localhost:8080/kholofedb
  at java.sql.DriverManager.getConnection(DriverManager.java:604)
  at java.sql.DriverManager.getConnection(DriverManager.java:221)
  at com.psybergate.database.SimbleCode.main(SimbleCode.java:21)
以下是我的源代码:

package com.psybergate.database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class SimbleCode 
{

    private static final String USER = "root" , PASS = "";


    public static void main(String ...args)
    {
        try {
            String connectionURL =       "dbc:mysql://localhost:8080/kholofedb";
               Class.forName("com.mysql.jdbc.Driver");
        //  Class.forName("org.postgresql.Driver");
            System.out.println("connecting to psysical database...");
            Connection conn = DriverManager.getConnection(connectionURL  , USER , PASS);

            Statement statement = conn.createStatement();
            System.out.println("Connection has been made");

            Scanner keyBoardScanner =  new Scanner(System.in);
            System.out.println("Enter table name:");
            String tableName = keyBoardScanner.nextLine();

            System.out.println("Creating table...");
            statement.executeQuery("create table " + tableName + " (name , age ,salary)");
            System.out.println("Table successfully created");
            System.out.println("Inserting data into the table ...");
            statement.executeUpdate("insert into " + tableName + "values (kholofelo , 21 , 9969696)");
        }
        catch (ClassNotFoundException | SQLException e) {

            e.printStackTrace();
        }

    }

}

提前感谢:)

您的连接字符串应该是:

String connectionURL = "jdbc:mysql://localhost:8080/kholofedb";

您的连接URL应该以“jdbc:”而不是“dbc:”

开始,现在我已经解决了这个问题,但是我遇到了另一个异常,我在使用postgresqlwhat exception时也遇到了这个异常?请检查您的端口是否为8080或3306。修复后,我收到此异常:通信链路故障成功发送到服务器的最后一个数据包是0毫秒前的。驱动程序尚未从服务器收到任何数据包。在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)在java.lang.reflect.Constructor.newInstance(Constructor.java:525)上在com.mysql.jdbc.Util.HandleneInstance(Util.java.mysql的默认端口是3306。也许最好试试这个:String connectionURL=“jdbc:mysql://localhost:3306/kholofedb";`通信链路故障上次成功发送到服务器的数据包是0毫秒前的。驱动程序尚未从服务器收到任何数据包。位于sun.reflect.NativeConstructorAccessorImpl.newInstance0`