Search Results

Search found 1191 results on 48 pages for 'jdbc'.

Page 16/48 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • How to manage a large dataset using Spring MySQL and RowCallbackHandler

    - by rmarimon
    I'm trying to go over each row of a table in MySQL using Spring and a JdbcTemplate. If I'm not mistaken this should be as simple as: JdbcTemplate template = new JdbcTemplate(datasource); template.setFetchSize(1); // template.setFetchSize(Integer.MIN_VALUE) does not work either template.query("SELECT * FROM cdr", new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { System.out.println(rs.getString("src")); } }); I get an OutOfMemoryError because it is trying to read the whole thing. Any ideas?

    Read the article

  • Connecting to Teradata via PHP

    - by AFHood
    We need to access a Teradata database via php application We don't have odbc (unixodbc etc) on the server. How might one go about connecting to a teradata database quickly. Keep in mind - this app needs to be as portable as possible.

    Read the article

  • problem using base64 encoder and InputStreamReader

    - by karoberts
    I have some CLOB columns in a database that I need to put Base64 encoded binary files in. These files can be large, so I need to stream them, I can't read the whole thing in at once. I'm using org.apache.commons.codec.binary.Base64InputStream to do the encoding, and I'm running into a problem. My code is essentially this FileInputStream fis = new FileInputStream(file); Base64InputStream b64is = new Base64InputStream(fis, true, -1, null); InputStreamReader reader = new InputStreamReader(b64is); preparedStatement.setCharacterStream(1, reader); When I run the above code, I get one of these during the execution of the update java.io.IOException: Underlying input stream returned zero bytes, it is thrown deep in the InputStreamReader code. Why would this not work? It seems to me like the reader would attempt to read from the base 64 stream, which would read from the file stream, and everything should be happy.

    Read the article

  • Best way to fetch data from a single database table with multiple threads?

    - by Ravi Bhatt
    Hi, we have a system where we collect data every second on user activity on multiple web sites. we dump that data into a database X (say MS SQL Server). we now need to fetch data from this single table from daatbase X and insert into database Y (say mySql). we want to fetch time based data from database X through multiple threads so that we fetch as fast as we can. Once fetched and stored in database Y, we will delete data from database X. Are there any best practices on this sort of design? any specific things to take care on table design like sharing or something? Are there any other things that we need to take care to make sure we fetch it as fast as we can from threads running on multiple machines? Thanks in advance! Ravi

    Read the article

  • Database connection timeout

    - by Clinton Bosch
    Hi I have read so many articles on the Internet about this problem but none seem to have a clear solution. Please could someone give me a definite answer as to why I am getting database timeouts. The app is a GWT app that is being hosted on a Tomcat 5.5 server. I use spring and the session factory is created in the applicationContext.xml as follows <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${connection.dialect}</prop> <prop key="hibernate.connection.username">${connection.username}</prop> <prop key="hibernate.connection.password">${connection.password}</prop> <prop key="hibernate.connection.url">${connection.url}</prop> <prop key="hibernate.connection.driver_class">${connection.driver.class}</prop> <prop key="hibernate.show_sql">${show.sql}</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.c3p0.min_size">5</prop> <prop key="hibernate.c3p0.max_size">20</prop> <prop key="hibernate.c3p0.timeout">1800</prop> <prop key="hibernate.c3p0.max_statements">50</prop> <prop key="hibernate.c3p0.idle_test_period">300</prop> </props> </property> <property name="annotatedClasses"> <list> <value>za.co.xxxx.traintrack.server.model.Answer</value> <value>za.co.xxxx.traintrack.server.model.Company</value> <value>za.co.xxxx.traintrack.server.model.CompanyRegion</value> <value>za.co.xxxx.traintrack.server.model.Merchant</value> <value>za.co.xxxx.traintrack.server.model.Module</value> <value>za.co.xxxx.traintrack.server.model.Question</value> <value>za.co.xxxx.traintrack.server.model.User</value> <value>za.co.xxxx.traintrack.server.model.CompletedModule</value> </list> </property> </bean> <bean id="dao" class="za.co.xxxx.traintrack.server.DAO"> <property name="sessionFactory" ref="sessionFactory"/> <property name="adminUsername" value="${admin.user.name}"/> <property name="adminPassword" value="${admin.user.password}"/> <property name="godUsername" value="${god.user.name}"/> <property name="godPassword" value="${god.user.password}"/> </bean> All works fine untile the next day: INFO | jvm 1 | 2010/06/15 14:42:27 | 2010-06-15 18:42:27,804 WARN [JDBCExceptionReporter] : SQL Error: 0, SQLState: 08S01 INFO | jvm 1 | 2010/06/15 14:42:27 | 2010-06-15 18:42:27,821 ERROR [JDBCExceptionReporter] : The last packet successfully received from the server was 38729 seconds ago.The last packet sent successfully to the server was 38729 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. INFO | jvm 1 | 2010/06/15 14:42:27 | Jun 15, 2010 6:42:27 PM org.apache.catalina.core.ApplicationContext log INFO | jvm 1 | 2010/06/15 14:42:27 | SEVERE: Exception while dispatching incoming RPC call I have read so many different things (none of which worked), please help

    Read the article

  • how to get the result query one by one in jsp and mysql

    - by user261002
    I am trying to implement as Online Mock exam in JSP, but I have a problem to get the questions one by one, it get connceted for the first time, and show me the first question and answers, but when I click on "next" again, it still show me the first question, I think by clicking on "next" it start querying again. please help me. this is my bean : database.SQLSelectStatement sqlselect; database.SQLSelectStatement sqlselect2; static ResultSet questions; static ResultSetMetaData rsm; static ResultSet answers; public void setConnection() throws SQLException { if (database.DatabaseManager.getInstance().connectionOK()) { sqlselect = new database.SQLSelectStatement("question", "question", "0"); sqlselect2 = new database.SQLSelectStatement("answers", "question_id", "0"); questions = sqlselect.executeWithNoCondition(); } } public int i=0; public String getQuestions() throws SQLException { String result = ""; rsm = questions.getMetaData(); for (int i = 0; i < rsm.getColumnCount(); i++) { result += "<th>" + rsm.getColumnName(i + 1) + "</th>"; } if (!questions.isLast()) { questions.next(); System.out.println(i+1); result += "<tr>"; result += "<td>" + questions.getInt(1) + "</td>"; result += "<td>" + questions.getString(2) + "</td>"; result += "</tr>"; result += "<tr>"; sqlselect2.setValue(String.valueOf(questions.getInt(1))); answers = sqlselect2.Execute(); while (answers.next()) { result += "<tr> <td colspan='2'><input type='radio' name='answer' value='" + answers.getString(2) + "'> " + answers.getString(2) + "</td></tr>"; } result += "</tr>"; answers.close(); } return result; } this is the HTML: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>JSP Page</h1> <jsp:useBean id="exam" class="exam.ExamQuestions"></jsp:useBean> <% exam.setConnection(); %> <form method="post"> <table > <%=exam.getQuestions()%> </table> <input type="submit" name="action" value="next"/> </form> <% String action = request.getParameter("action"); if ("next".equals(action)) { out.println(request.getParameter("answer")); } %> </body> </html>

    Read the article

  • Cannot read value from SYS_CONTEXT

    - by AppleGrew
    I have a PL/SQL procedure which sets some variable in user session, like the following:- Dbms_Session.Set_Context( NAMESPACE =>'MY_CTX', ATTRIBUTE => 'FLAG_NAME', Value => 'some value'); Just after this (in the same procedure), I try to read the value of this flag, using:- SYS_CONTEXT('MY_CTX', 'FLAG_NAME'); The above returns nothing. How did the DB lose this value? The weirder part is that if I invoke this proc directly from Oracle SQL Developer then it works. It doesn't work when I invoke this proc from my web application from callable statement. --EDIT-- Added an example as to how we are invoking the proc from our Java code. String statement = "Begin package_name.proc_name( flag_val => :1); END;"; OracleCallableStatement st = <some object by some framework> .createCallableStatement(statement); st.setString(1, 'flag value'); st.execute(); st.close();

    Read the article

  • Building resultset using collection object

    - by Bhaskara Krishna Mohan Potam
    Hi, I had an issue in building the resultset using java. Here it goes... I am storing a collection object which is organized as row wise taken from a resultset object and putting the collection object(which is stored as vector/array list) in cache and trying to retrieve the same collection object. Here i need to build back the resultset again using the collection object. Now my doubt is building the resultset in this way possible or not? Please let me know asap. Thanks in advance, Bhaskar

    Read the article

  • optimistic locking batch update

    - by Priit
    How to use optimistic locking with batch updates? I am using SimpleJdbcTemplate and for single row I can build update sql that increments version column value and includes version in WHERE clause. Unfortunately te result int[] updated = simpleJdbcTemplate.batchUpdate does not contain rowcounts when using oracle driver. All elements are -2 indicating unknown rowcount. Is there some other, more performant way of doing this than executing all updates individually? These batches contain an average of 5 items (only) but may be up to 250.

    Read the article

  • Where to store a DataSource resource in a Java web app?

    - by Slavko
    This is a rookie question. What's the best place to put @Resource private DataSource ds; in a web application? Do I put it in a servlet, context listener or maybe there's a better place for it? Also, do I create a new Connection object in my doGet()/doPost() or should I do it somewhere else? What's the best practice for stuff like this? Thank you!

    Read the article

  • Invoking a PL/SQL function from EclipseLink

    - by Mark Robinson
    I'm trying to execute a PL/SQL function in EclipseLink which uses Oracle Specific types(eg. Boolean). I've tried using PLSQLStoredProcedureCall which complains that I'm not executing a procedure and I have tried using StoredFunctionCall but that returns PLS-00382: expression is of wrong type Has anyone developed a solution to invoke functions in EclipseLink with Oracle Types? I have heard that it would be possible to extend StoredFunctionCall but I'd rather leverage existing functionality as much as possible.

    Read the article

  • JBoss warning - "Unable to fill pool"

    - by Marcus
    We're getting this random warning from JBoss.. any idea why? It happens at random times when there are no active threads. Everything works when any processing resumes. 13:49:31,764 WARN [JBossManagedConnectionPool] [ ] Unable to fill pool org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Listener ref used the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack The Connection descriptor used by the client was: //localhost:1521/orcl

    Read the article

  • Oracle doesn't remove cursors after closing result set

    - by Vladimir
    Note: we reuse single connection. ************************************************ public Connection connection() {                try {            if ((connection == null) || (connection.isClosed()))            {               if (connection!=null) log.severe("Connection was closed !");                connection = DriverManager.getConnection(jdbcURL, username, password);            }        } catch (SQLException e) {            log.severe("can't connect: " + e.getMessage());        }        return connection;            } ************************************************** public IngisObject[] select(String query, String idColumnName, String[] columns) { Connection con = connection(); Vector<IngisObject> objects = new Vector<IngisObject>(); try {     Statement stmt = con.createStatement();     String sql = query;     ResultSet rs =stmt.executeQuery(sql);//oracle increases cursors count here     while(rs.next()) {        IngisObject o = new IngisObject("New Result");        o.setIdColumnName(idColumnName);                    o.setDatabase(this);        for(String column: columns) o.attrs().put(column, rs.getObject(column));        objects.add(o);        }     rs.close();// oracle don't decrease cursor count here, while it's expected     stmt.close();     } catch (SQLException ex) {     System.out.println(query);     ex.printStackTrace(); }

    Read the article

  • How to log all sql going through JBoss datasource with log4j

    - by Ichorus
    I've looked at log4jdbc (which does not support datasources), p6spy which seems to be what I am looking for but it has not been updated since 2003 which makes me nervous and lists only JBoss 3.x (we use JBoss 5), and JAMon which seems heavyweight for what I am trying to accomplish (a simple log of all SQL statements running through a JBoss application server). I was hoping that JBoss itself would have a switch to log all the sql (as Websphere does) but I cannot find any documentation for it so that functionality might not exist.

    Read the article

  • Correct way to make datasources/resources a deploy-time setting

    - by Draemon
    I have a web-app that requires two settings: A JDBC datasource A string token I desperately want to be able to deploy one .war to various different containers (jetty,tomcat,gf3 minimum) and configure these settings at application level within the container. My code does this: InitialContext ctx = new InitialContext(); Context envCtx = (javax.naming.Context) ctx.lookup("java:comp/env"); token = (String)envCtx.lookup("token"); ds = (DataSource)envCtx.lookup("jdbc/datasource") Let's assume I've used the glassfish management interface to create two jdbc resources: jdbc/test-datasource and jdbc/live-datasource which connect to different copies of the same schema, on different servers, different credentials etc. Say I want to deploy this to glassfish with and point it at the test datasource, I might have this in my sun-web.xml: ... <resource-ref> <res-ref-name>jdbc/datasource</res-ref-name> <jndi-name>jdbc/test-datasource</jndi-name> </resource-ref> ... but sun-web.xml goes inside my war, right? surely there must be a way to do this through the management interface Am I even trying to do the right thing? Do other containers make this any easier? I'd be particularly interested in how jetty 7 handles this since I use it for development. EDIT Tomcat has a reasonable way to do this: Create $TOMCAT_HOME/conf/Catalina/localhost/webapp.xml with: <?xml version="1.0" encoding="UTF-8"?> <Context antiResourceLocking="false" privileged="true"> <!-- String resource --> <Environment name="token" value="value of token" type="java.lang.String" override="false" /> <!-- Linking to a global resource --> <ResourceLink name="jdbc/datasource1" global="jdbc/test" type="javax.sql.DataSource" /> <!-- Derby --> <Resource name="jdbc/datasource2" type="javax.sql.DataSource" auth="Container" driverClassName="org.apache.derby.jdbc.EmbeddedDataSource" url="jdbc:derby:test;create=true" /> <!-- H2 --> <Resource name="jdbc/datasource3" type="javax.sql.DataSource" auth="Container" driverClassName="org.h2.jdbcx.JdbcDataSource" url="jdbc:h2:~/test" username="sa" password="" /> </Context> Note that override="false" means the opposite. It means that this setting can't be overriden by web.xml. I like this approach because the file is part of the container configuration not the war, but it's not part of the global configuration; it's webapp specific. I guess I expect a bit more from glassfish since it is supposed to have a full web admin interface, but I would be happy enough with something equivalent to the above.

    Read the article

  • how to handle result set data

    - by ashwani66476
    Hello All I am getting lacks of records in my Result Set. My concerns are : How Result Set handle these records internally? and How a programmer can handle those records in batches So that memory problem would not occur.? waiting for your answers .. Many Thanks

    Read the article

  • How do I return a nested table from an oracle function using Java?

    - by Benny
    I have the following type declaration and Oracle function: CREATE OR REPLACE TYPE var_outcomes_results IS TABLE OF VARCHAR2(80); CREATE OR REPLACE FUNCTION getValuesAbove(in_nodeID IN table1.KEY_SL%TYPE, in_variable IN VARCHAR2) RETURN var_outcomes_results IS currentID table1.KEY_SL%TYPE; results var_outcomes_results; currentIndex integer := 0; BEGIN currentID := in_nodeID; WHILE currentID != null LOOP FOR outcomeRecord IN (select distinct a.PARENT, b.NAME, c.OUTCOME from table1 a left outer join table2 b on a.KEY_SL = b.KEY_SL left outer join table3 c on b.VAR_ID = c.VAR_ID where a.KEY_SL = currentID) LOOP currentID := outcomeRecord.PARENT; IF lower(outcomeRecord.NAME) = lower(in_variable) AND outcomeRecord.OUTCOME != null THEN currentIndex := currentIndex + 1; results(currentIndex) := outcomeRecord.OUTCOME; END IF; END LOOP; END LOOP; RETURN results; END; I have the following Java function: public List<Object> getAboveValues(String variable, Integer nodeID) { Connection connection = null; CallableStatement callableStatement = null; try { connection = dataSource.getConnection(); callableStatement = connection.prepareCall("begin ? := getValuesAbove(?,?); end;"); callableStatement.registerOutParameter(1, OracleTypes.ARRAY); callableStatement.setInt(2, nodeID); callableStatement.setString(3, variable); callableStatement.execute(); System.out.println(callableStatement.getObject(1)); } catch( SQLException e ) { logger.error("An Exception was thrown in getAboveValues: " + e); } finally { closeDataResources(callableStatement, connection); } } However, when I execute the function, I get the following error message: "ORA-03115: unsupported network datatype or representation" What am I doing wrong? Any ideas/suggestions would be appreciated. Thanks, B.J.

    Read the article

  • Binding a null variable in a PreparedStatement

    - by Paul Tomblin
    I swear this used to work, but it's not in this case. I'm trying to match col1, col2 and col3, even if one or more of them is null. I know that in some languages I've had to resort to circumlocutions like ((? is null AND col1 is null) OR col1 = ?). Is that required here? PreparedStatement selStmt = getConn().prepareStatement( "SELECT * " + "FROM tbl1 " + "WHERE col1 = ? AND col2 = ? and col3 = ?"); try { int col = 1; setInt(selStmt, col++, col1); setInt(selStmt, col++, col2); setInt(selStmt, col++, col3); ResultSet rs = selStmt.executeQuery(); try { while (rs.next()) { // process row } } finally { rs.close(); } } finally { selStmt.close(); } // Does the equivalient of stmt.setInt(col, i) but preserves nullness. protected static void setInt(PreparedStatement stmt, int col, Integer i) throws SQLException { if (i == null) stmt.setNull(col, java.sql.Types.INTEGER); else stmt.setInt(col, i); }

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >