Tag: oracle

oracle 11g和hibernate spring和jsf的集成

我正在使用jsf 2,hibernate 4.1.4,spring 3.1,oracle 11g和maven 3.但它无法连接到oracle并且有错误。 我下载了最新版本的ojdbc6。 applicationContext.xml中 model.Customer org.hibernate.dialect.Oracle10gDialect true 脸,配置 org.springframework.web.jsf.el.SpringBeanFacesELResolver web.xml中 jsfspringhiber org.springframework.web.context.ContextLoaderListener contextConfigLocation /WEB-INF/applicationContext.xml org.springframework.web.context.request.RequestContextListener javax.faces.PROJECT_STAGE Development default.xhtml Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet *.xhtml /faces/* State saving method: ‘client’ or ‘server’ (=default). See JSF Specification 2.5.2 javax.faces.STATE_SAVING_METHOD client javax.servlet.jsp.jstl.fmt.localizationContext resources.application com.sun.faces.config.ConfigureListener CustomerDaoImpl.java public class CustomerDaoImpl implements ICustomerDao{ private SessionFactory sessionFactory; […]

如何在Java代码中解析ORA-01795

我在Java代码中执行ORA-01795错误,同时在IN子句中执行超过1000条记录。 我正在考虑使用由OR子句分隔的多个IN子句在1000个条目的批处理中打破它,如下所示: select * from table_name where column_name in (V1,V2,V3,…V1000) or column_name in (V1001,V1002,V1003,…V2000) 我有一个字符串ID,如-18435,16690,1719,1082,1026,100759…它是根据用户选择动态生成的。 如何在Java中为1-1000条记录,1001条到2000条记录等条件编写逻辑。 有人能帮我一下吗?

无法从mybatis执行的oracle过程中接收参数

我使用Spring 3.0.5开发java应用程序,并使用mybatis-spring使用数据库Oracle。 我有一个mybatis界面: public interface SubscriberMapper { Subscriber getSubscriberByMsisdn(String msisdn); void insertSubscriber(Subscriber subscriber); void updateSubscriber(Subscriber subscriber); void canCustomerSubscribe(@Param(“msisdn”) String msisdn, @Param(“responseCode”) Integer responseCode); } canCustomerSubscribe的mybatis xml内容: CALL wallet.pkg_wallet_validation.can_customer_subscribe(#{msisdn}, #{responseCode}) 和要执行的代码: public void subscribe(String msisdn) throws InvalidArgumentException { Integer responseCode = 0; subscriberMapper.canCustomerSubscribe(msisdn, responseCode); System.out.println(“msisdn: ” + msisdn + “, responseCode: ” + responseCode); } 当我用无效的“msisdn”执行“subscribe”方法时,我没有收到来自程序的实际值。 […]

“ORA-01008:并非所有变量都绑定”错误

我使用以下方法通过使用jdbc计算工资单,但“ORA-01008:并非所有变量绑定”错误都没有删除。 有什么想法吗? 我正在使用以下代码 public double getPayroll(){ ResultSet rs = null; ResultSet rs1 = null; ResultSet rs2 = null; Connection conn = null; PreparedStatement pstmt = null; try { conn = getDBConnection(); double dailyPay=0,basicPay=0,payroll2=0; int houseRent=0,convAllow=0,noOfPresents=0,empId=0; String q = “select e_id from employee”; pstmt = conn.prepareStatement(q); rs = pstmt.executeQuery(); while (rs.next()) { empId=rs.getInt(1); String q1 = […]

如何在JDBC中调用存储过程

对于家庭作业,我必须创建一个pl / sql存储过程来将一个facutly成员添加到数据库 CREATE OR REPLACE PROCEDURE ADDFACULTYDEPTSAL (facid IN NUMBER, facname IN VARCHAR, depID IN NUMBER) AS sal NUMBER; BEGIN CALCSALDEPT(depID, sal); IF sal >= 50000 THEN sal := sal*.9; ELSE IF sal >= 30000 THEN sal := sal*.8; END IF; END IF; INSERT INTO FACULTY(fid, fname, deptid, salary) VALUES(facid, facname, depID, sal); END […]

在查询中使用带间隔的prepareStatement时出错

运行此查询时SELECT SYSDATE + INTERVAL ‘7’ DAY FROM DUAL; 在像这样的prepareStatement PreparedStatement ps = connection.prepareStatement(“select sysdate + interval ? day from dual” ); ps.setString(1, “7”); ps.executeQuery(); 它会抛出exception,语法不好,显然是,因为我能够在sql-developer中运行相同的查询。 这是PreparedStatement的错误吗? 我可以将预备语句与间隔一起使用吗?

Java:在oracle数据库中调用存储过程

编辑:虽然这个问题的一些答案可以帮助其他人解决不同的问题,但解决方案实际上与数据库连接上的自动提交function有关! 在执行查询后强制提交导致数据库反映更改,因此下面显示的代码是调用此类存储过程的正确方法 我试图在oracle数据库中调用一个简单的存储过程。 该过程如下所示: procedure clear_orderProcDtlByOrdId(p_order_id in order_header.order_id%type, p_transaction_id in sl_order_processing_dtl.transaction_id%type DEFAULT NULL, p_item_action_id in sl_order_processing_dtl.item_action_id%type DEFAULT NULL ) … 我遇到麻烦的java代码看起来像这样 try { CallableStatement storedProc = conn.prepareCall(“{call PKG_PI_FRAUD.clear_orderProcDtlByOrdId(?)}”); storedProc.setString(1, orderID); storedProc.execute(); } catch (SQLException e) { e.printStackTrace(); } 我根本没有收到任何错误,但没有反映数据库更改。 当我在SQL Developer中运行该过程时,我看到了结果。 我认为这可能是因为提交问题,但我建立的连接处于自动提交模式。 任何帮助,将不胜感激!

ORA-12505:TNS监听器当前不知道连接描述符中给出的SID

我正在使用Oracle数据库。 我用Java编写了一个小的JDBC连接程序,但是我遇到了一个监听器的问题。 import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class JdbcConnection { public static void main(String[] args) throws SQLException,ClassNotFoundException { String url = “jdbc:oracle:thin:@localhost:1521:orcl”; String user = “system”; String password = “password”; Connection connection = null; Class.forName(“oracle.jdbc.driver.OracleDriver”); connection = DriverManager.getConnection(url, user, password); if(connection!=null){ System.out.println(“Success in connnection”); } else { System.out.println(“failure in […]

java.library.path中没有ocijdbc9

当我尝试运行Java应用程序时,收到以下错误: Exception in thread “main” java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path 我的电脑上没有文件ocijdbc9.* ,但我在%ORACLE_HOME%\bin有ocijdbc10.dll 。 %ORACLE_HOME%被正确指定,所以我认为问题是应用程序正在搜索错误的版本(9而不是10)。 Oracle和Java Builder都是新安装的,所以问题可能出在项目首选项中? 您对如何搜索指定了错误版本的地方有任何想法吗?

为什么我一直收到“java.lang.AbstractMethodError:oracle.jdbc.driver.OracleConnection”错误? 它让我疯狂。 。

我已经读过为什么在尝试在db中加载blob时会得到java.lang.AbstractMethodError? ,下载了我能找到的所有11g jdbc驱动程序,并将它们作为库和/或jar文件添加到我的NetBeans应用程序中。 我仍然继续得到相同的AbstractMethodError,这让我变得多了! 任何指导将不胜感激! try { stmt = conn.createStatement(); inputFileInputStream = new FileInputStream(inputBinaryFile); Blob vBlob = conn.createBlob(); BufferedImage vGImage=ImageIO.read(name); int offset =0; OutputStream out = vBlob.setBinaryStream(offset); ImageIO.write(vGImage, “JPG”, out); PreparedStatement stat = conn.prepareStatement(“INSERT INTO item VALUES (?,?,?,?,?)”); stat.setString(1, itemNo); stat.setString(2, itemName); stat.setBlob(3,vBlob); stat.setString(4, invenType); stat.setDouble(5, vPrice); stat.executeUpdate(); } catch (IOException e) { System.out.println(“Caught I/O […]