第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

各位幫我看看哪里有問題,我是按視頻一步一步敲的代碼,把testProcedure函數(shù)run as 后出現(xiàn)Class not found demo.oracle.TestProcedure?

package?demo.utils;

import?java.sql.Connection;
import?java.sql.DriverManager;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?java.sql.Statement;


public?class?JDBCUtils?{
	private?static?String?driver?=?"oracle.jdbc.OracleDriver";
	private?static?String?url?=?"jdbc:oracle:thin:@localhost:zhang0519";
	private?static?String?user?=?"scott";
	private?static?String?password?=?"tiger";
	
	//注冊數(shù)據(jù)庫驅(qū)動
	static{

		try?{
			Class.forName(driver);
		}?catch?(ClassNotFoundException?e)?{
			throw?new?ExceptionInInitializerError(e);
		}
	}
	
	//獲取數(shù)據(jù)庫連接
	public?static?Connection?getConnection(){
		try?{
			return?DriverManager.getConnection(url,user,password);
		}?catch?(SQLException?e)?{
			e.printStackTrace();
		}
		return?null;
	}
	
	//釋放數(shù)據(jù)庫的資源
	public?static?void?release(Connection?conn,Statement?st,ResultSet?rs){
		if(rs?!=?null){
			try?{
				rs.close();
			}?catch?(SQLException?e)?{
				e.printStackTrace();
			}finally{
				rs?=?null;
			}
			
		}
		
		if(st?!=?null){
			try?{
				st.close();
			}?catch?(SQLException?e)?{
				e.printStackTrace();
			}finally{
				st?=?null;
			}
		}
		
		if(conn?!=?null){
			try?{
				conn.close();
			}?catch?(SQLException?e)?{
				e.printStackTrace();
			}finally{
				conn?=?null;
			}
		}
	}
	
}
package?demo.oracle;

import?java.sql.CallableStatement;
import?java.sql.Connection;

import?org.junit.Test;

import?demo.utils.JDBCUtils;
import?oracle.jdbc.driver.OracleTypes;

public?class?TestProcedure?{

	@Test
	public?void?testProcedure(){
		String?sql?=?"{call?queryempinf(?,?,?,?)}";
		Connection?conn?=?null;
		CallableStatement?call?=?null;
		try?{
			//得到一個連接
			conn?=?JDBCUtils.getConnection();
			
			//通過連接創(chuàng)建Statement
			call?=?conn.prepareCall(sql);
			
			//對于in參數(shù),賦值
			call.setInt(1,7839);
			
			//對于out參數(shù),申明
			call.registerOutParameter(2,?OracleTypes.VARCHAR);
			call.registerOutParameter(3,?OracleTypes.NUMBER);
			call.registerOutParameter(4,?OracleTypes.VARCHAR);
			
			//執(zhí)行調(diào)用
			call.execute();
			
			//取出結(jié)果
			String?name?=?call.getNString(2);
			double?sal?=?call.getDouble(3);
			String?job?=?call.getNString(4);
			System.out.println(name+"\t"+sal+"\t"+job);
		}?catch?(Exception?e)?{
			e.printStackTrace();
		}finally{
			JDBCUtils.release(conn,?call,?null);
		}
		
	}
}


正在回答

2 回答

你的URL設(shè)置的有問題:private?static?String?url?=?"jdbc:oracle:thin:@localhost:zhang0519";

這個是我本地的:private static String url = "jdbc:oracle:thin:@localhost:1521:orcl";

注意格式:jdbc:oracle:thin:@localhost:端口號:數(shù)據(jù)庫名 ? ?注意這里的漢字部分,且是以冒號隔開的


1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕粉3439686 提問者

非常感謝!
2016-10-22 回復(fù) 有任何疑惑可以回復(fù)我~
異常如下:
Class?not?found?demo.oracle.TestProcedure
java.lang.ClassNotFoundException:?demo.oracle.TestProcedure
	at?java.net.URLClassLoader.findClass(Unknown?Source)
	at?java.lang.ClassLoader.loadClass(Unknown?Source)
	at?sun.misc.Launcher$AppClassLoader.loadClass(Unknown?Source)
	at?java.lang.ClassLoader.loadClass(Unknown?Source)
	at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:685)
	at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:421)
	at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
	at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

各位幫我看看哪里有問題,我是按視頻一步一步敲的代碼,把testProcedure函數(shù)run as 后出現(xiàn)Class not found demo.oracle.TestProcedure?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號