如何为Oracle SQL Developer加载JDBC驱动程序 [英] How to load JDBC driver for Oracle SQL Developer
问题描述
我的教授要求我们制作一个 java 程序,要求用户输入数据,并且输入的数据应自动插入到 sql developer 中的表中. /p>
我有Java和数据库方面的背景知识,但是我对创建JDBC应用程序不熟悉.
我在线搜索了一个教程,它说我需要先注册JDBC驱动程序.我在编译器中运行了代码,但输出为Error: unable to load driver class!
.
我应该怎么做才能注册?
我仍然不知道Class.forName();
其次,它会错误地显示SQLException: No suitable drivers found
我不知道我的代码有什么问题,但是我的SQL开发人员中的连接详细信息是这样的:
连接名称:mariel
连接详细信息:mariel @///localhost:1521/XEXDB
代码:
import java.sql.* ;
public class employeeMode{
public static void main(String args[]) throws SQLException{
String URL = "jdbc:oracle:thin:@localhost:1521:XEXDB";
String USER = "mariel";
String PASS = "1234";
Connection conn = DriverManager.getConnection(URL, USER, PASS);
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver class!");
System.exit(1);
}
}
}
我修好了它!谢谢大家!这是工作代码:
import java.sql.* ;
public class employeeMode{
public static void main(String args[]) throws SQLException{
String URL = "jdbc:oracle:thin:mariel@//localhost:1521/XEXDB";
String USER = "mariel";
String PASS = "1234";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(URL, USER, PASS);
}
catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver class!");
System.exit(1);
}
}
}
@Mariel, 您是否已安装Oracle 10g或任何版本的数据库, 我认为Class.forName("oracle.jdbc.driver.OracleDriver");找不到您已安装系统的任何数据库连接
从驱动器下面下载ojdbcxxx.jar文件 http://www.oracle.com/technetwork/database/features /jdbc/index-091264.html
My professor asks us to make a java program that asks the user to input the data and the data inputted should automatically be inserted into a table in sql developer.
I have a background in Java and database but i'm not familiar with creating JDBC applications.
I searched a tutorial online and it said that i need to register the JDBC driver first. I ran the code in my compiler but it outputs Error: unable to load driver class!
.
What should i do for it to register?
I still don't know the concept of Class.forName();
Secondly, it errors a SQLException: No suitable drivers found
I don't know what's wrong in my code but the connection details in my SQL developer is this:
Connection name: mariel
Connection details: mariel@//localhost:1521/XEXDB
The code:
import java.sql.* ;
public class employeeMode{
public static void main(String args[]) throws SQLException{
String URL = "jdbc:oracle:thin:@localhost:1521:XEXDB";
String USER = "mariel";
String PASS = "1234";
Connection conn = DriverManager.getConnection(URL, USER, PASS);
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver class!");
System.exit(1);
}
}
}
EDIT:
I fixed it! Thank you everyone! here's the working code:
import java.sql.* ;
public class employeeMode{
public static void main(String args[]) throws SQLException{
String URL = "jdbc:oracle:thin:mariel@//localhost:1521/XEXDB";
String USER = "mariel";
String PASS = "1234";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(URL, USER, PASS);
}
catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver class!");
System.exit(1);
}
}
}
@Mariel, have you installed Oracle 10g or any version Database, i think Class.forName("oracle.jdbc.driver.OracleDriver"); is unable to find any database connection which you have installed your system
download ojdbcxxx.jar file from below drive http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
这篇关于如何为Oracle SQL Developer加载JDBC驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!