Inserting Information in PostgreSQL interval

Hey,
I am having trouble entering intervals into a PostgreSQL inverval field. Currently I using prepared statements that look like this:
PreparedStatement query = conn.prepareStatement("INSERT............");
query.setObject(1, "{28.1, 29.2}");
query.setObject(2, "{1:23, 1:24}");
query.execute();And when I execute the code I get this error:
org.postgresql.util.PSQLException: ERROR: column "field_1" is of type interval[] but expression is of type character varying
So is there another way of entering an array of intervals into a postgresql database using prepared statement? What am I doing wrong?

I was also given another solution:
query.setObject(7, {2:03, 2:05}, Types.OTHER);
Now here is another question/problem. PostgreSQL DB stores it at {02:03:00,02:05:00} which is 2 hours, and 3 minutes when it was supposed be stored at 2 minutes and 3 seconds. Is there anything in the database insert statement that I could add to make it start at the lowest value of time instead of the highest? Or is this something that I have to manually put a 00: ex:{00:02:03, 00:02:05} at front of everything?

Similar Messages

  • I have a form that has multiple fields but has 5 sections. I have used mail merge to insert information but I can't get Excel to recognize that I need different names and addresses for each section. Please help.

    I have a form that has multiple fields but has 5 sections. I have used mail merge to insert information but I can't get Excel to recognize that I need different names and addresses for each section. Please help.

    Thanks for your response. I do believe I have the information needed for each form on a separate line in Excel. There is a first name, middle name, last name, city, and zip column. And field is entered on a different line for all the information. I'm really stuck.

  • Servlet inserting record into postgresql through hibernate

    Hi
    I have developed a servlet. This servlet is inserting record into postgres sql through hibernate using eclispe ide. When I run my code then I find the following exception
    exception
    java.lang.NullPointerException
         hibernate.example.FirstExample.doGet(FirstExample.java:54)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    I have developed the following code
    package hibernate.example;
    public class Contact {
         private String firstName;
         private String lastName;
         private String email;
         private long id;
         public String getEmail() {
         return email;
         public String getFirstName() {
         return firstName;
         public String getLastName() {
         return lastName;
         public void setEmail(String string) {
         email = string;
         public void setFirstName(String string) {
         firstName = string;
         public void setLastName(String string) {
         lastName = string;
         public long getId() {
         return id;
         public void setId(long l) {
         id = l;
    **Now the servlet is**
    package hibernate.example;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.Configuration;
    public class FirstExample extends HttpServlet     {
         Session session = null;
         public String getServletInfo() {
              return "Servlet connects to PostgreSQL database and displays result of a SELECT";
         public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException {
              try{
                   response.setContentType("text/html");
                   PrintWriter out = response.getWriter();
                   Configuration cfg = new Configuration().configure();
                   SessionFactory factory = cfg.buildSessionFactory();
                   session = factory.openSession();
                   out.println("Inserting Record");
                   Contact contact = new Contact();
                   contact.setId(6);
                   contact.setFirstName("Deepak");
                   contact.setLastName("Kumar");
                   contact.setEmail("[email protected]");
                   session.save(contact);
                   out.println("Done");
              catch(Exception e){
                   System.err.println(e.getMessage());
              finally{
                   session.flush();
                   session.close();
    **web.xml is**
    <web-app>
              <database>
                   <driver>
                   <type>org.postgresql.Driver</type>
              <url>jdbc:postgresql://127.0.0.1:5432/ali</url>
              <user>ali</user>
              <password>ali</password>
                   </driver>
              </database>
              <servlet>
              <servlet-name>FirstExample</servlet-name>
              <servlet-class>hibernate.example.FirstExample</servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name>FirstExample</servlet-name>
              <url-pattern>/hb</url-pattern>
              </servlet-mapping>
    </web-app>
    **And contact.hbm.xml is**
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
    <class name="hibernate.example.Contact" table="CONTACT">
    <id name="id" type="long" column="ID" >
    <generator class="assigned"/>
    </id>
    <property name="firstName">
    <column name="FIRSTNAME" />
    </property>
    <property name="lastName">
    <column name="LASTNAME"/>
    </property>
    <property name="email">
    <column name="EMAIL"/>
    </property>
    </class>
    </hibernate-mapping>
    **And hibernate.cfg.xml is**
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    <session-factory>
    <property name="hibernate.connection.driver_class">com.postgressql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:postgresql://127.0.0.1:5432/ali</property>
    <property name="hibernate.connection.username">ali</property>
    <property name="hibernate.connection.password">ali</property>
    <property name="hibernate.connection.pool_size">10</property>
    <property name="show_sql">true</property>
    <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <property name="hibernate.hbm2ddl.auto">update</property>
    <!-- Mapping files -->
    <mapping resource="contact.hbm.xml"/>
    </session-factory>
    </hibernate-configuration>
    Pleas tell me that where I have done the mistake and how can I resolove the error.

    ahmadgee wrote:
    Thank u very much.
    First I tried with out the servlet. I took a simple class. But it was displaying the null pointer exception.
    then you still have the problem. do you understand the root cause?
    After then I made a servlet. how was that going to help your null pointer exception?
    Now it is displaying error hibernate.cfg.xml not found.that's part of the problem. where is the servlet reading that file and initializing the session factory? how is it finding that file?
    i don't know where you have that .cfg.xml file, or where the recommended place is where hibernate expects to see it, but i'd bet it needs to be in the CLASSPATH, which means WEB-INF/classes.
    figure out why you get that NPE first, though. the servlet is only making things worse.
    %

  • I need to re-insert information into add-ons that need it everytime i restart my computer.

    Everytime I restart my computer and open Firefox, I have to re-insert certain information into specific add-ons.
    For instance, "Firefox Sync" doesn't sync until I enter my Firefox Sync account information as if I just installed it. This happens everytime I restart.
    And "Webmail Notifier" loses my webmail account information. I have to re-enter the credentials for the 3 accounts I want it watching everytime I restart my laptop.
    Out of all my add-ons, I think those are the only two having problems. Any suggestions?
    All my plug-ins seem up to date, no viruses/spyware...

    You may have a problem with the preferences file, for details on fixing that see https://support.mozilla.com/kb/Preferences+are+not+saved

  • Problem inserting String into postgresql.

    Hello,
    I have this code in postgresql:
    select merge_db(3, 1, '1901-1-1', '1901-1-1', '1901-1-1', 1, 1, 1, 1, 1, 1 , 1, 'hola', 1);
    That calls the function merge_db and inserts data, but it wont work in my java program:
    String queryPostgresql = "select merge_db("+ oid +", "+ uid +", to_timestamp("+ etime +"), to_timestamp("+ pstime +"), to_timestamp("+ rstime +"), "+ elapsed +", "+ espera +", "+ numcpu +", "+ numcpu +", "+ memory +", "+ error +", "+ memory +", "+ etiqueta +", "+ finalizado +")";
    The main problem is in the field "etiqueta" which is varchar in sql and String in java. It throws "ERROR: the column (content of the variable) does not exist"
    Also I'm not completely confident about the timestamp fields, I think they are causing problems too.
    This is the merge_db function:
    create function merge_db(key int, data1 int, data2 timestamp with time zone , data3 timestamp with time zone, data4 timestamp with time zone, data5 int, data6 int, data7 int, data8 int, data9 int, data10 int, data11 int, data12 text, data13 int) returns void as
    $$
    begin
    loop
    update trabajos set time_elapsed = data5 where oid = key;
    if found then
    return;
    end if;
    begin insert into trabajos(oid,uid,fecha_fin,fecha_acept,fecha_exec,time_elapsed,espera,ncpu,rec_ncpu,rec_memoria,error,memoria,etiqueta,finalizado) values (key, data1, data2, data3, data4, data5, data6, data7, data8, data9, data10, data11, data12, data13);
    return;
    exception when unique_violation then
    end;
    end loop;
    end;
    $$
    language plpgsql;
    Thank you!

    Here is my code then:
    Connection connPostgresql = DriverManager.getConnection(myUrlPostgresql, "database", "pass");
    Statement StmtPostgresql = connPostgresql.createStatement();
    String queryPostgresql = "select merge_db("+ oid +", "+ uid +", to_timestamp("+ etime +"), to_timestamp("+ pstime +"), to_timestamp("+ rstime +"),
    "+ elapsed +", "+ espera +", "+ numcpu +", "+ numcpu +", "+ memory +", "+ error +", "+ memory +", "+ etiqueta +", "+ finalizado +")";
    StmtPostgresql.executeUpdate(queryPostgresql);The function in postgresql is this one:
    create function merge_db(key int, data1 int, data2 timestamp with time zone , data3 timestamp with time zone,
    data4 timestamp with time zone, data5 int, data6 int, data7 int, data8 int, data9 int, data10 int, data11 int, data12 text, data13 int)
    returns void as
    $$
    begin
    loop
    update trabajos set time_elapsed = data5 where oid = key;
    if found then
    return;
    end if;
    begin
    insert into trabajos(oid,uid,fecha_fin,fecha_acept,fecha_exec,time_elapsed,espera,ncpu,rec_ncpu,rec_memoria,error,memoria,etiqueta,finalizado)
    values (key, data1, data2, data3, data4, data5, data6, data7, data8, data9, data10, data11, data12, data13);
    return;
    exception when unique_violation then
    end;
    end loop;
    end;
    $$
    language plpgsql;The problem is when i try to use preparedstatement i won't work and throw that exception.
    And another question (I'm a pain in the ass): Java is throwing an exception regarding postgresql that says "org.postgresql.util.PSQLException: A result was returned when none was expected"
    Thank you very much.
    Edited by: 850264 on 13/04/2011 08:31

  • Inserting Information into Existing Custom Data Object Using API?

    Hello,
    I have setup a Custom Object and I have the ID for this object. All we're wanting to insert in this object is First Name, Last Name, Email. I have that information in code-form and I have both the BULK API and REST api at our disposal. We are having issues figuring out the API call we want to execute to insert this information into this Custom Object.
    If someone could point us in the right direction that would be amazing. Thank you!

    I solved the problem.
    when we are selecting the image data from access database select that as getbytes
              while(rs.next())
                   count++;
                   picbarray = rs.getBytes("PICTURE");     
    when inserting to the oracle db
    PreparedStatement st1 = null;
    String sql = "insert into (colmn1,colmn2,colmn3,comn4,colmn5) values(?,?,?,?,?)";
    st1 = con.prepareStatement(sql);     
    st1.setString(1, val1);
         st1.setString(2, val2);
         st1.setString(3, val3);
         st1.setBytes(4, picbarray);     
    st1.setString(5, val5);
         st1.executeUpdate();

  • Autofill inserts information not in my address card

    When I try to enter 3 digits of my Canadian postal code which is T3L, autofill shows the full postal code, but when I tab out of the postal code field, Safari replaces the postal code with 3-0. I have had this happen before. How can I stop this incorrect replacement by autofill without turning autofill off?
    It is not a problem with the website, because it works correctly with Firefox. I also tried it with my office postal code which begins T2L and autofill replaces it with 2-1. If I use my parents' postal code it works?? It seems that this problem is something between my address card and autofill. I have checked the data in my card in Address book (it is OK and the character sequences that autofill puts in are not present anywhere on my address card) and deleted the information about this website from the autofill preferences list of websites in Safari.
    Any suggestions?

    Just trying to ping this so I might get someone who knows something about it.

  • Most robust way to preserve data insert into CLOB?

    Hello.
    When inserting data into a CLOB column, some of the characters are not being preserved, such as ellipsis characters and other unusual characters. The data is being inserted via JDBC as a simple Java string sql statement in a Statement object. So, what is the most appropriate way to insert information into a CLOB such that all characters are preserved? (Do I have to use PreparedStatements or Clob.setString()?)
    For example, the following sql insert:
    "INSERT INTO t1 (myClob) VALUES ('Hello ... how are you?');"
    Will end up inserting something like:
    "Hello ? how are you?"
    The ellipsis character (Unicode U+2026, I believe) is changed to something else. How can I preserve this and other characters? Thanks in advance.

    Hi,
    Must have something to do with NCHAR or Unicode characters.
    Here are the notes i put in chapter 8 of my book, section 8.2.2
    Notes:
    Pre-10.2 JDBC does not support NCHAR literal (n'...') containing
    Unicode characters that cannot be represented in the database character
    set.
    Using 10.2 JDBC against 10.2 RDBMS, NCHAR literals (n'...')
    are converted to Unicode literals (u'...'); non-ASCII characters
    are converted to their corresponding Unicode escape sequence.
    Using 10.2 JDBC against pre-10.2 RDBMS, NCHAR literals (n'...') are
    not converted and generate undetermined content for characters that
    cannot be represented in the database character set.
    Fwiw, here is my blog entry relative to Lobs (CLOB, BLOB, BFILE) :
    http://db360.blogspot.com/2006/11/get-bolder-with-lobs-manipulation-in.html
    Kuassi, http://db360.blogspot.com/2006/08/oracle-database-programming-using-java_01.html

  • Xsql multiple table insert

    I'm having trouble getting my xml document inserted into multiple tables. My xml has a parent child relationship. The main node is the parent I'll call <CAKE> then later on in the xml doc it has a node called <INGREDIENTS> which is a repeating element (more than 1). I need to insert information from the root node, <CAKE> into 1 table and all the info from <INGREDIENTS> node into another table.
    I've tried to get Steve Muench's book a try (chapter 14) but when I try to run the examples from the book (XMLLoader) i get the following error.
    C:\jdev9i\jdk1.3\bin\javaw.exe -ojvm -classpath C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\oracle\ora81\RDBMS\jlib\xsu12.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\jdev\lib\jdev-rt.jar;C:\jdev9i\jdbc\lib\classes12.jar;C:\jdev9i\jdbc\lib\nls_charset12.jar;C:\jdev9i\jlib\jdev-cm.jar;C:\jdev9i\rdbms\jlib\xsu12.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\lib\xmlcomp.jar;C:\jdev9i\lib\oraclexsql.jar;C:\jdev9i\rdbms\jlib\xsu12.jar;C:\jdev9i\lib\xsqlserializers.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes -
    mx50m
    XMLLoader -file deptempdepend.xml -transform deptempdepend.xsl
    Processed 1 Documents
    Node doesn't belong to the current document.
    Error: java.lang.NullPointerException
    Process exited with exit code 0.

    I made the changes in the java files as per the previous
    reference, but I'm still getting an error. Seeing that I'm not
    much of a Java guy yet, I'm not sure where to debug the error.
    So here it is:
    XMLLoader -file deptempdepend.xml -transform deptempdepend.xsl
    Processed 1 Documents
    null
    Error: java.lang.NullPointerException
    Process exited with exit code 0.
    I tried to debug it and came to the conclusion that it is
    failing at line 22 of ConnectionFactory
    The value connNode is returend as null.
    I don't understand why:
    I ran testxpath.exe for the connections file.
    C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14>testxpath connections.xml
    Type an XPath expression to test and press [Enter]
    To quit, press [Enter] without entering a path.
    connections.xml> /connections/connection[@name='doug']
    <connection name="doug">
    <username>user</username>
    <password>password</password>
    <dburl>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
    (CONNECT_DATA=(SERVICE_NAME=dtxml.hmms)))</dburl>
    <driver>oracle.jdbc.driver.OracleDriver</driver>
    </connection>
    connections.xml>
    and it returned what i thought would be the correct nodes.
    Any help would be appreciated
    Doug

  • How to put info in infotype PA0138 ( familymember information )

    I ame making a application with WD ABAP and I need to store data from family members (child, spousse).
    General data from familymembers is stores in PA0021, no problem here but information like
                           'Tax Charged'   ( output: checkbox )
                           'Disability'          ( output: checkbox )
    from familymembers should also be stored.
    I dont manage to insert information in PA0138, any ideas why not or solution ?
    thnx in advance.

    Hi,
    You can simply go for infotype enhancement for required z fields, or can call dynamic action to maintain 0138 after the maintainenance of 0021
    Regards,
    Kapil

  • Syntax eror in INSERT INTO satement

    I get this when i try to insert information in the database:
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in
    INSERT INTO statement.
    thanks for the help in advanced

    Epid3mik
    > I get this when i try to insert information in the
    database:
    I suspect some of your column names are reserved keywords,
    such as FROM, TIME, etcetera.
    http://support.microsoft.com/kb/286335
    Whenever possible, avoid using keywords as object names. The
    better solution here is to permanently rename the columns that are
    keywords. Assuming the rest of your query syntax is correct, that
    should fix the syntax error. If for some reason you cannot rename
    the columns, you must escape them by using square brackets around
    the column names:
    INSERT INTO Message ( mem_id, [From], [Time], .... )
    As an aside, you should properly scope your variables.
    Example use #FORM.mem_id# instead of just #mem_id#. Your should
    also consider using cfqueryparam for all query values. These last
    two things are not the cause of your error, but they are good
    coding practices.

  • Insert a frame or window into adobe acrobat  or reader window

    Using Windows OS XP or Vista. Can you ad a frame or window into the main window to allow saving a document through another application? I have an application that routes save documents to specific folders depending on the type of document. I would like to be able to allow my clients to open or create a PDF and then have the option to use the application through a frame or window displayed under the "pages" or "bookmarks" area of Adobe reader. Is this possible and can you point me in the right direction.

    Leonard - Could this "new" window contain a custom form as an object. we have used it in Microsoft Outlook with success for customers to insert information pertinent to an email item and then save the item to our application. What I am looking for is to allow our clients to open a pdf or create one and be able to save it as always but with the option to open this "pane" and enter information needed by our routing application. if this is possible can you point me to specific area to start looking as the SDK is very large and informative. I am lookg for a good starting point.
    thanks

  • How to create a fillable form without distribution information?

    I'm looking to create an informational sheet (PDF) in which some of my offices can insert their own contact information into a single box.  I want to get rid of the purple box on the top of the form which talks about distribution which will confuse many.  Is it possible to create a plain PDF with one box to insert information into without all the fancy stuff to send the form back? I don't need to track it or get it back!
    Thanks

    Hi llvi56,
    You might want to refer the KB : http://helpx.adobe.com/acrobat/kb/create-fillable-pdf-forms-acrobat.html

  • Inserting Multiple instances into a databse

    I am using MySQL to capture the form data. In the form I have a Driver License section which can have multiple instances.
    In the workflow I am using the "Execute SQL query" module to insert data. Initially I can insert information from the non-repeating subforms, successfully. However, workflow inserts no information from repeating subforms. Below is an example of the XPATH used.
    /process_data/xfaform/object/data/xdp/datasets/data/App/DriverLicense/drvlicstate
    Is the above format correct ? How can I insert the second and third instances ?
    Thanks
    Aditya

    Yes you can and will have to set up a loop in your process. Use an integer process variable as your loop increment start it at 1 (I'm pretty sure the indexing begins at 1...could be 0). You'll have to use the count() XPath function to count the number of nodes. Something like...
    count(/process_data/xfaform/object/data/xdp/datasets/data/App/DriverLicense/drvlicstate)
    Compare that number with the index value to know if you've looped through every node (and inserted each, one at a time) or if you need to loop again. Email me and I'd be glad to discuss this further with you if need be. It's not as complicated as it sounds.
    Hope this helps!
    Ryan D. Lunka
    Cardinal Solutions Group
    [email protected]

  • HOW to connect to a user in the postgresql

    Hi,
    Can any one please help me how to connect to a postgresql and information on postgresql
    Than & Regards
    Poorna Prasad

    Not sure about the help but fail to understand though why would one ask about Postgresql over Oracle's forums?
    http://www.google.co.in/search?q=HOW+to+connect+to+a+user+in+the+postgresql++&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
    HTH
    Aman....

Maybe you are looking for

  • How to make an alert view without buttons on iphone?

    Hi, I'm trying to create an alert view without buttons. On my iphone application I have to run a process, while the process is running I want to display an alert view with info about the process, and then when the process is done I want to dismiss th

  • It wont Shut Down or Restart

    I am having problems with the Shutting or restart option it wont take either command. What can I do to fix the problem?

  • Now that I've added extra RAM...

    ...that is now 3GB of RAM on 2.16ghz 667Mhz processor...I haven't yet noticed anything new other than RAM preview in MOTION 3 is faster. I'd like some opinions from others who have done this and wether the $90 expense is worth it and what advantages

  • Iphoto Library: Data Folder versus Originals Folder

    Hi. I've been trying to save some space. I realized that I have the same photo stored in 3 different folders: my personal file folder (from where I imported), and within the "iphoto library" in 2 different folders: Originals and Data Folder. I got ri

  • Help...LR3 flash gallery preview not working.

    Oddly enough, I had a similar problem with LR3b2, but solved it by allowing lightroom to connect to the internet (saving that setting on the firewall), but now that I've purchased LR3, the flash gallery preview is NOT working. I've tried the followin