[英]No suitable driver found
I am trying to execute a sql query in java 6: 我正在尝试在Java 6中执行sql查询:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**
*
* @author ramy
*/
public class JavaTest
{
public static void main(String[] args)
{
try
{
String url="jdbc:msql://127.0.0.1:1521;DatabaseName=test";
Connection ct=DriverManager.getConnection(url,"","");
Statement st=ct.createStatement();
ResultSet result;
result=st.executeQuery("select * from utente");
while(result.next())
{
String temp=result.getString("Num_tessera");
System.out.println(temp);
}
ct.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
I have installed mysql 5.5 cluster on Mac Os X, in the url I have just written my local IP (localhost), and the database name is test. 我已经在Mac Os X上安装了mysql 5.5群集,在该URL中,我刚刚编写了本地IP(本地主机),数据库名称为test。
Why doesn't it find the database? 为什么找不到数据库? Do I have to install some driver?
我必须安装一些驱动程序吗? I already have the database installed and "utente" is an existing table.
我已经安装了数据库,“ utente”是一个现有表。
I suspect the problem is your JDBC URL: 我怀疑问题出在您的JDBC URL:
"jdbc:msql://..."
Did you mean 你的意思是
"jdbc:mysql://..."
by any chance? 在任何情况下?
(And yes, you'll also need the MySQL driver in your classpath. It's not something you need to install , but the jar file will need to be available.) (是的,在类路径中还需要MySQL驱动程序 。不需要安装它 ,但是jar文件将需要可用。)
确保您的类路径中有MySQL JDBC驱动程序。
还请检查URL中的端口,因为1521是Oracle,MySQL是3306
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.