找不到合适的驱动程序

编程入门 行业动态 更新时间:2024-10-27 22:32:14
本文介绍了找不到合适的驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在Java 6中执行sql查询:

I am trying to execute a sql query in java 6:

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()); } } }

我已经在Mac Os X上安装了mysql 5.5集群,在URL中,我刚刚编写了本地IP(本地主机),数据库名称为test. 为什么找不到数据库?我必须安装一些驱动程序吗?我已经安装了数据库,"utente"是一个现有表.

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. 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.

推荐答案

我怀疑问题是您的JDBC URL:

I suspect the problem is your JDBC URL:

"jdbc:msql://..."

你的意思是

"jdbc:mysql://..."

有没有机会?

(是的,您也还需要 MySQL驱动程序在您的类路径中.安装不需要它,但是jar文件将需要可用.)

(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.)

更多推荐

找不到合适的驱动程序

本文发布于:2023-10-18 23:39:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1505756.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   驱动程序   合适

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!