Postgres:没有为jdbc找到合适的驱动程序

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

我知道这可能是此处发布的问题的重复。对不起。这是我为数据库连接写的代码

I know this might be a possible duplicate of question posted here. Sorry for that.Here is the code i wrote for Database connection

try{ Class.forName("org.postgresql.Driver"); } catch(ClassNotFoundException e) { e.printStackTrace(); } try{ String URL = "jdbc:posgresql://localhost:5432/postgres"; String USER = "postgres"; String PASS = "postgres"; Connection conn = DriverManager.getConnection(URL, USER, PASS); Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("Select * from employee"); while(rs.next()){ System.out.println(rs.getString(1)); } } catch(SQLException es){ es.printStackTrace(); }

运行此代码时出现以下异常:

While running this code i get the following exception :

java.sql.SQLException: No suitable driver found for jdbc:posgresql://localhost:5432/postgres at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at ManageEmployee.main(ManageEmployee.java:60)

我在eclipse中构建了这个项目并添加了外部jar的postgres

I have built this project in eclipse and added the external jar of postgres

这是.classpath文件是否有帮助

Here is the .classpath file if it might help

<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> <attributes> <attribute name="owner.project.facets" value="java"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> <classpathentry kind="lib" path="//10.202.6.95/kavitha_share/jars/postgresql-8.2-504.jdbc2ee.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath>

因为我已经添加了罐子,可能是什么原因?

what could be the possible reason as i have already added the jars ??

推荐答案

将 posgresql 更改为 postgresql 。

jdbc:posgresql://localhost:5432/postgres

变为:

jdbc:postgresql://localhost:5432/postgres

请注意pos t中的字符' t ' gresql

Please note the character 't' in postgresql

更多推荐

Postgres:没有为jdbc找到合适的驱动程序

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

发布评论

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

>www.elefans.com

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