Help need on inserting system date on database

hello every body,
I need to insert system date into database through prepared statement.
i wrote code :
java.util.Date d=new java.util.Date();
Preparestatement psmt;
psmt.setDate(8, java.sql.Date(d));
am getting class cast exception :
could u please tell me how to insert system date through prepared statement..
thanks in advance..

Surround your code with a
try{
//Insert date here
catch(Exception e){
//handle exceptions here
e.printStackTrace();
Who says he didn't already?
Try this:
java.util.Date d=new java.util.Date();
>
Preparestatement psmt;
psmt.setDate(8, new
java.sql.Date(d.getTime()));This is correct, but can be condensed (if you want)
psmt.setDate(8, new java.sql.Date(new java.util.Date().getTime()));
>
It's good idea to use the JDBC escape function
instead of using a specific DBMS function. This way,
your code will be portable.
sql = "INSERT INTO USERS VALUES("
+ "'" + userName + "'" + ","
+ "'" + userPw   + "'" + ","
+ "  {fn now() }  )"; e Real's How To
(http://64.18.163.122/rgagnon/javadetails/java-0567.ht
ml)
And this is only marginally applicable.  If he wishes to use the same statement for the current date, as well as other dates, he cannot make use of this.  Of course, I don't really know if I would trust or recommend a tutorial site that advocates building statements that are screaming for injection attack attempts.
Edit:  Too slow by a mile!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Help needed regarding insertion of data into oracle

    Hi,
    I am student currently trying to do a project to up a semantic database using oracle. Have set up the semantic technologies for oracle 11gr2 and used the jena adapter to load an owl into oracle.
    But i am not sure how do i insert sample data that could reference the owl.
    Tried searching but unable to find any simple tutorial and have also looked through the developer's guide and also jenaadaptor guide.
    Is there any tutorials available that could help? thank you

    Hi,
    Please go to the OTN site for more information:
    http://www.oracle.com/technology/tech/semantic_technologies/index.html
    There you can find some training info (try the NCI Oracle By Example, it's a good tutorial):
    http://www.oracle.com/technology/tech/semantic_technologies/htdocs/semtech_training.html
    Regards,
    Vladimir

  • Help needed badly Insert text data from xml files into tables

    Hi all, I have asked to do insertion of text from a xml file into tables upon receiving using pro*c. i've done quite an amount of research on xml parser in c but there wasn't much information for mi to use for implementation...
    Guys don't mind helping me to clarify few doubts of mine...
    1. Where can i get the oracle xml parser libs? Is it included when i installed oracle 8i?
    2. Is there any tutorials or help files for xml parser libs where i can read up?
    I need the xml parser to recognise the tags, followed by recognising the text after the tags.
    eg. xml format
    <studentID> 0012 </studentID>
    <student> john </student>
    <studentID> 0013 </studentID>
    <student> mary </student>
    text willl be inserted into tables like this:
    studentID | student
    0012 | john
    0013 | mary
    by the way i'm using oracle 8i on HP-UX. Thanks in advance.

    I can answer one of of your questions at least
    1. Where can i get the oracle xml parser libs? Is it included when i installed oracle 8i?You need the XML XDK. You can use http://www.oracle.com/technology/tech/xml/xdkhome.html as your starting point. I believe the 9i version works for 8i.
    I have no pro*c experience so I can't offer any other suggestions regarding how to do this in pro*c.

  • Inserting blob data into database

    Hello everybody,
    I need insert blob data into database. that data i need to get from form
    can i use request.getParameter(""); for getting that file.
    Plz help how to get data from form to servlet and through callablestatement i need to insert into database.
    regards,
    Anil

    Hi,
    1) first create a form with file element
    first.jsp
    <form action="GetData" enctype="multipart/form-data" method="post">
    <input type="file" name="datafile" size="40">
    <input type="submit" value="Send">
    <input type="reset" name="Reset" value="Cancel">
    </form>
    GetData.java
    // servlet file
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    res.setContentType("text/html");
    PrintWriter out = response.getWriter();
    try {
    System.setProperty( "jdbc.drivers", "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
    Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
    con = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=JAVATEAM;SelectMethod=cursor;User=sa;Password=urpassword" );
    PreparedStatement pst = con.prepareStatement("insert into uploads(binaryfile) values(?)");
    FileInputStream fis=new FileInputStream(request.getParameter ( "datafile" ) );
    byte[] b= new byte[fis.available()+1];
    fis.read(b);
    pst.setBytes(1,b);
    pst.executeUpdate();
    pst.close();
    con.close();
    catch(SQLException e)
    out.println ( e);
    catch (ClassNotFoundException e)
    out.println( e );
    }Here in doPost(), i create preparedstatement,
    now you to create one procedure for insert
    and by using callable statement you just call that procedure and pass this byte b as arguments,
    now its in your hands
    my idea is over.

  • Help needed to insert data from different database

    Hi ,
    I have a requirement where i need to fetch data from different database through database link .Depending on user request , the dblink needs to change and data from respective table from mentioned datbase has to be fetched and populated .Could i use execute immediate for this, would dblink work within execute immediate .If not , could pls let me know any other approach .

    What does "the dblink needs to change" mean?
    Are you trying to dynamically create database links at run-time? Or to point a query at one of a set of pre-established database links at run-time?
    Are you sure that you really need to get the data from the remote database in real time? Could you use materialized views/ Streams/ etc to move the data from the remote databases to the local database? That tends to be far more robust.
    Justin

  • Help needed in inserting data using a query

    I need to have some data as a result of the following query:
    select sched_num,load_id,ord_id,split_id from ord_load_seq
    where (ord_id,split_id,sched_num) in (select ord_id,split_id,sched_num from ord_load_seq where seq_num = '2'
    group by ord_id,split_id,sched_num having count(1) >1)
    order by ord_id,split_id,sched_num;
    But currently it retunrns no rows. The problem is in the having count(1)> 1 clause.
    When i make =1, it returns rows. But no rows on > 1. I even tried inserting some rows to get the result >1
    But still the query on a whole returns no rows.Please help.

    ohhh... lets start our lesson children:
    here is code to consider:
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
    SQL>
    SQL> --Q1
    SQL> with tbl as
      2  (select 1 fld1, 1 fld2, 1 fld3 from dual
      3  union all
      4  select 1 fld1, 1 fld2, 2 fld3 from dual
      5  union all
      6  select 1 fld1, 1 fld2, 3 fld3 from dual
      7  union all
      8  select 1 fld1, 2 fld2, 3 fld3 from dual
      9  union all
    10  select 1 fld1, 3 fld2, 3 fld3 from dual)
    11  select  fld1, fld2, fld3 from tbl
    12  order by fld1, fld2, fld3
    13  /
          FLD1       FLD2       FLD3
             1          1          1
             1          1          2
             1          1          3
             1          2          3
             1          3          3
    SQL> --Q2
    SQL> with tbl as
      2  (select 1 fld1, 1 fld2, 1 fld3 from dual
      3  union all
      4  select 1 fld1, 1 fld2, 2 fld3 from dual
      5  union all
      6  select 1 fld1, 1 fld2, 3 fld3 from dual
      7  union all
      8  select 1 fld1, 2 fld2, 3 fld3 from dual
      9  union all
    10  select 1 fld1, 3 fld2, 3 fld3 from dual)
    11  select  fld1, fld2, fld3, count(1) from tbl
    12  group by fld1,fld2,fld3
    13  order by fld1, fld2, fld3
    14  /
          FLD1       FLD2       FLD3   COUNT(1)
             1          1          1          1
             1          1          2          1
             1          1          3          1
             1          2          3          1
             1          3          3          1
    SQL> --Q3
    SQL> with tbl as
      2  (select 1 fld1, 1 fld2, 1 fld3 from dual
      3  union all
      4  select 1 fld1, 1 fld2, 2 fld3 from dual
      5  union all
      6  select 1 fld1, 1 fld2, 3 fld3 from dual
      7  union all
      8  select 1 fld1, 2 fld2, 3 fld3 from dual
      9  union all
    10  select 1 fld1, 3 fld2, 3 fld3 from dual)
    11  select  fld1, fld2, fld3 from tbl
    12  group by fld1,fld2,fld3
    13  having count(1) > 1
    14  order by fld1, fld2, fld3
    15  /
          FLD1       FLD2       FLD3
    SQL> --Q4
    SQL> with tbl as
      2  (select 1 fld1, 1 fld2, 1 fld3 from dual
      3  union all
      4  select 1 fld1, 1 fld2, 2 fld3 from dual
      5  union all
      6  select 1 fld1, 1 fld2, 2 fld3 from dual
      7  union all
      8  select 1 fld1, 1 fld2, 3 fld3 from dual
      9  union all
    10  select 1 fld1, 2 fld2, 3 fld3 from dual
    11  union all
    12  select 1 fld1, 3 fld2, 3 fld3 from dual)
    13  select  fld1, fld2, fld3 from tbl
    14  order by fld1, fld2, fld3
    15  /
          FLD1       FLD2       FLD3
             1          1          1
             1          1          2
             1          1          2
             1          1          3
             1          2          3
             1          3          3
    6 rows selected
    SQL> --Q5
    SQL> with tbl as
      2  (select 1 fld1, 1 fld2, 1 fld3 from dual
      3  union all
      4  select 1 fld1, 1 fld2, 2 fld3 from dual
      5  union all
      6  select 1 fld1, 1 fld2, 2 fld3 from dual -- inserted duplicate row
      7  union all
      8  select 1 fld1, 1 fld2, 3 fld3 from dual
      9  union all
    10  select 1 fld1, 2 fld2, 3 fld3 from dual
    11  union all
    12  select 1 fld1, 3 fld2, 3 fld3 from dual)
    13  select  fld1, fld2, fld3, count(1)   from tbl
    14  group by fld1,fld2,fld3
    15  order by fld1, fld2, fld3
    16  /
          FLD1       FLD2       FLD3   COUNT(1)
             1          1          1          1
             1          1          2          2
             1          1          3          1
             1          2          3          1
             1          3          3          1
    SQL> --Q6
    SQL> with tbl as
      2  (select 1 fld1, 1 fld2, 1 fld3 from dual
      3  union all
      4  select 1 fld1, 1 fld2, 2 fld3 from dual
      5  union all
      6  select 1 fld1, 1 fld2, 2 fld3 from dual -- inserted duplicate row
      7  union all
      8  select 1 fld1, 1 fld2, 3 fld3 from dual
      9  union all
    10  select 1 fld1, 2 fld2, 3 fld3 from dual
    11  union all
    12  select 1 fld1, 3 fld2, 3 fld3 from dual)
    13  select  fld1, fld2, fld3 from tbl
    14  group by fld1,fld2,fld3
    15  having count(1) > 1
    16  order by fld1, fld2, fld3
    17  /
          FLD1       FLD2       FLD3
             1          1          2
    SQL> Q1. As you may see we have an bunch of data where each row is unique combination of the columns value.
    Q2. lets try to group it by fld1 and fld2 and fld3 columns. We don't expect any miracle and got the same data as Q1. Why? Because each row is unique combination(group) in scope of fld1, fld2, fld3 - count(1) exactly shows us that.
    Q3. Q2 is explanation why we got no rows filter (having count(1) > 1)because the result of the clause is always false.
    Q4. Lets put some duplication.
    Q5. Now we got some new result. Count shows us group with more then one rows.
    Q6. Shows us exact group which we've found in Q5.

  • Need to place the data from database to right position in jsp page

    hello all java prople.. i m disigning a jsp page menu..which is having deep 4 level menu.. means one heading & 4 sub menu of each menus.. which is containing data from sql database...
    i can manage connection in between jsp page & d database.. but to place the data in right position is very typical....
    i need dyanamic insertion or deletion of menu item from the database..... help me out

    This has completely nothing to do with JDBC.
    I'll give you only a hint then: "hierarchial data". Google it in combination with some smart keywords, such as "SQL" or "database".

  • Help needed in reading text file to database table

    Hello experts,
    i have to insert the values from the column of this text file and insert them in my database table.
    I have done a few file to table insertions but i'm having some trouble with this one.
    Any suggestions plz
    thanks
    liab_report      1.00                                                                                                                              Page: 1
    CDC:00537 / Mon Jun-21-2010                           LIABILITY REPORT                               Mon Jun-21-2010 22:06:26
    DRAW    1; SET    1;  November 7, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         701040.00          0.00     660146.00          0.00      40894.00    0.00          0.00
        Div3        1444128.00          0.00    1330056.00          0.00     114072.00    0.00          0.00
        Div4        4711900.00          0.00    3889700.00          0.00     822200.00    0.00          0.00
                    6857068.00          0.00    5879902.00          0.00     977166.00    0.00          0.00
    DRAW    2; SET    1;  November 14, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         817817.00          0.00     817817.00          0.00          0.00    0.00          0.00
        Div3        1687405.00          0.00    1611742.00          0.00      75663.00    0.00          0.00
        Div4        3402100.00          0.00    3034200.00          0.00     367900.00    0.00          0.00
                    5907322.00          0.00    5463759.00          0.00     443563.00    0.00          0.00
    DRAW    3; SET    1;  November 21, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         779933.00          0.00     769804.00          0.00      10129.00    0.00          0.00
        Div3        1605548.00          0.00    1525104.00          0.00      80444.00    0.00          0.00
        Div4        4891700.00          0.00    4256800.00          0.00     634000.00    0.00        900.00
                    7277181.00          0.00    6551708.00          0.00     724573.00    0.00        900.00

    Plz clarify whether u want to load text file as a file into database or value of this text file into database. If values are to be loaded from this text file, U can better format the text file and use SQL loader to load the file into database. By formatting the database, i mean remove the unnecessary headings and characters, kee only the values to be loaded idelimited by ' '(space) or ','(comma). Create a control file and load it into the target table.

  • Urgent help needed in inserting data into a custom table in oracle WorkFlow

    Hi
    I am trying to get data from the WF and insert into a custom table..
    I read that workflow procedures WONT allow commits...
    Oracle Workflow will not support autonomous commits in any procedure it calls directly. If you need to perform commits, then embed your SQL in a subprocedure and declare it as an autonomous block. This subprocedure must be capable of being rerun. Additionally, note that Oracle Workflow handles errors by rolling back the entire procedure and setting its status to ERROR. Database updates performed by autonomous commits cannot be rolled back, so you will need to write your own compensatory logic for error handling
    Have anyone did this..
    Please give me some idea ...It is urgent
    I am getting data using getitemattribute..and try to insert it into a custom table
    thanks
    kp

    Pl do not post duplicate threads - insert dont work in Workflow
    Srini

  • Need help toUpdate or insert in to AS400 database

    Hi all,
    I have created one scenario in which I am using JDBC receiver adapter,
    now the database at the end which is to be updated is the AS400 database
    which has the concept of liabraries and staging tables.
    while mapping the Inbound message type I use the structure as
    <MT>
      <Statement>
           <Tablename>
                  action
                <access>
                      <field1>
                      <field2>
                <key>
    I assign a const. 'update_insert' to action attrib. but when I activate the adapter at the end the error I get is :
    'field1' column does not exists in 'Tablename'
    But when I use a JAVA code for doing the same the data is successfully updated on the database.
    I tried the same thing using MS Access database it works fine but not AS400
    need help.
    Thanks
    Ranjit

    Ranjith,
    The process is the very same for  AS400 too. We are doing operations with AS400 and we dint face any problems. Hope you have already deployed the JDBC drivers in your XI server.
    Change your Data type slightly.
    <MT>
    <Statement>
    <table action = UPDATE_INSERT>
    <table>specify the table name in library.table  name eg: LIBRARY.TABLE1</table>
    <access>
    <field1>a</field1>
    <field2>2</field2>
    <access>
    <key>
    <field1>a</field1>
    </key>
    </Statement>
    </MT>
    Regards,
    Jai Shankar

  • Pls help me to automatically replicate data from database server to other server

    i have one database which is in oracle running on NT platform..this database gets updated every min..automatically with the data comming from Global positioning system(GPS)
    there is another application wich is running on solaris platform
    NOw the problem is that when ever data get's inserted into database of NT platform that data should get reflected in to the database of solaris platform.
    I did study something abt replication..but i am not getting it..
    will any help me w.r.t this..This is of high priority to me ...
    with regards,
    jagadeesh
    null

    I used ./exp utility to export the db.More...
    if you set the correct PATH, $export PATH=$ORACLE_HOME/bin:$PATH in environment, you do not need to run ./exp but direct exp will work.
    In 11g I used "./imp" utility to import database. Then I got following erroralso you should be using expdp/impdp (data pump)

  • Help needed in deleting nodes from RAC database

    Our DB is 10g RAC database and the servers are Window 2003 server. Initially the database was configured to have 4 nodes. For some reason we stopped the instances in the first two nodes and the current database is running on node3 and node4. I queried the v$thread view and it shows 3 records. Thread 2 is closed and disabled. Thread 3 is open and public and thread 4 is open and private. Now we need to disconnect nodes 1 and 2 from RAC db and cluster ware (We use Oracle cluster ware) and plan to use those two servers for other purposes. Although I read through the Oracle doc regarding deleting node from RAC “11 Adding and Deleting Nodes and Instances on Windows-Based Systems” and wrote down the steps we need to take but I am still not comfortable in doing it since it is production env and we don’t have any dev env to practice those steps. So I would like to borrow your experiences and your lessons learned while you were doing those. Please share your thoughts and insights with us.
    Thank you so much for your help,
    Shirley

    what's your full version? I can warn about specific issues in 10.1.0.3 and 10.2.0.1 - for example, in some cases (depending on how the listener was configured), it will be impossible to delete the listener for the deleted node. Known bug.
    To avoid many many known bugs, you may want to upgrade to at least 10.2.0.2 before removing a node (from my experience, this is the first stable RAC version).
    In any case, deleting a node is a rather delicate process. I really really recommend practicing. Take any pc/laptop, install VMWARE, define two virtual machines, install RAC and remove one node. It will take you an extra day or two, and could save your production.

  • HELP NEEDED !! Null values in Database

    Hi there !!
    I need help with EJB 3.0 passing null values to database. The situation looks like that :
    I have created EJB entity class called "Osoba.java", it is in relation
    with "Rola.java" (one to many). Each Object of class Osoba can have
    many Roles. Then I created "OsobaServiceBean.java " I included it with
    metod "CreateUnregisteredOsoba(Osoba , Boolean)". From "flex" level I
    call this bean - call is accepted, and as a result new object of class Osoba is added to database. Problem is that only one column is filled in table,
    dispite that in service bean I enforce it to fill all columns (see
    source code - file OsobaServiceBean.java , method
    createUnregisteredOsoba() )
    I provided source code here :
    FILE Rola.java
    package test.granite.ejb3.entity ;
    import javax.persistence.Basic;
    import javax.persistence.CascadeType;
    import javax.persistence.Entity;
    import javax.persistence.ManyToOne;
    @Entity
    public class Rola extends AbstractEntity {
    private static final long serialVersionUID = 1L;
    @Basic
    private String login = new String("");
    @Basic
    private String rola = new String("");
    @Basic
    private String roleGroup = new String("");
    @Basic
    private Boolean zatwierdzony = new Boolean(false);
    @ManyToOne(optional=false)
    private Osoba osoba;
    public Boolean getZatwierdzony() {
    return zatwierdzony;
    public void setZatwierdzony(Boolean zatwierdzony) {
    this.zatwierdzony = zatwierdzony;
    public String getLogin() {
    return login;
    public void setLogin(String login) {
    this.login = login;
    public String getRola() {
    return rola;
    public void setRola(String rola) {
    this.rola = rola;
    public Osoba getOsoba() {
    return osoba;
    public void setOsoba(Osoba osoba) {
    this.osoba = osoba;
    public String getRoleGroup() {
    return roleGroup;
    public void setRoleGroup(String roleGroup) {
    this.roleGroup = roleGroup;
    FILE Osoba.java
    package test.granite.ejb3.entity ;
    import java.util.HashSet;
    import java.util.Set;
    import javax.persistence.Basic;
    import javax.persistence.CascadeType;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.OneToMany;
    @Entity
    public class Osoba extends AbstractEntity {
    private static final long serialVersionUID = 1L;
    @Basic
    private String imie;
    @Basic
    private String nazwisko;
    @Basic
    private String login;
    @Basic
    private String haslo;
    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER,
    mappedBy="osoba")
    private Set<Rola> role = new HashSet<Rola>();
    @Basic
    private String email;
    @Basic
    private String nrTelefonu;
    @Basic
    private int rokStudiow;
    public String getPelneImie() {
    StringBuilder sb = new StringBuilder();
    if (imie != null && imie.length() > 0)
    sb.append(imie);
    if (nazwisko != null && nazwisko.length() > 0) {
    if (sb.length() > 0)
    sb.append(' ');
    sb.append(nazwisko);
    return sb.toString();
    public String getImie() {
    return imie;
    public void setImie(String imie) {
    this.imie = imie;
    public String getNazwisko() {
    return nazwisko;
    public void setNazwisko(String nazwisko) {
    this.nazwisko = nazwisko;
    public String getLogin() {
    return login;
    public void setLogin(String login) {
    this.login = login;
    public String getHaslo() {
    return haslo;
    public void setHaslo(String haslo) {
    this.haslo = haslo;
    public Set<Rola> getRole() {
    return role;
    public void setRole(Set<Rola> role) {
    this.role = role;
    public String getEmail() {
    return email;
    public void setEmail(String email) {
    this.email = email;
    public String getNrTelefonu() {
    return nrTelefonu;
    public void setNrTelefonu(String nrTelefonu) {
    this.nrTelefonu = nrTelefonu;
    public int getRokStudiow() {
    return rokStudiow;
    public void setRokStudiow(int rokStudiow) {
    this.rokStudiow = rokStudiow;
    FILE OsobaServiceBean.java
    package test.granite.ejb3.service;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;
    import javax.annotation.security.RolesAllowed;
    import javax.ejb.Local;
    import javax.ejb.Stateless;
    import javax.persistence.Query;
    import org.jboss.annotation.security.SecurityDomain ;
    import test.granite.ejb3.entity.Osoba;
    import test.granite.ejb3.entity.Rola;
    @Stateless
    @Local(OsobaService.class)
    @SecurityDomain("other")
    public class OsobaServiceBean extends AbstractEntityService implements
    OsobaService{
    private static final long serialVersionUID = 1L;
    public OsobaServiceBean() {
    super();
    public List<Osoba> findAllOsoba() {
    return findAll(Osoba.class);
    @SuppressWarnings("unchecked")
    public List<Osoba> findAllOsoba(String name) {
    Query query = manager.createQuery (
    "select distinct p from Osoba p " +
    "where upper(p.imie) like upper('%" + name + "%')
    or upper(p.nazwisko) like upper('%" + name + "%')"
    return query.getResultList();
    public Osoba createOsoba(Osoba person) { // pozwalamy
    tworzyc zeby niezalogowany
    return manager.merge (person); //
    uzytkownik utworzyl osobe
    } // ale
    osoba ta i tak nie bedzie jeszcze
    // zatwierdzona
    @RolesAllowed({"unregistered"})
    public Osoba createUnregisteredOsoba(Osoba person, boolean
    zatwierdzony) {
    Rola niezarejestrowany = new Rola();
    niezarejestrowany.setRola("user");
    niezarejestrowany.setOsoba(person);
    niezarejestrowany.setRoleGroup("Roles");
    niezarejestrowany.setLogin(person.getLogin());
    niezarejestrowany.setZatwierdzony(zatwierdzony);
    Set<Rola> role = new HashSet<Rola>();
    role.add(niezarejestrowany);
    // Arrays;
    Object a[] = role.toArray();
    Rola temp;
    temp = (Rola)a[0];
    System.out.println("Login = " + temp.getLogin() + //
    added only for check !!
    "Rola = " + temp.getLogin() +
    "Zatwierdzony = " +
    temp.getZatwierdzony() +
    "Rolegroup = " + temp.getRoleGroup());
    person.setRole (role);
    return manager.merge(person); //
    uzytkownik utworzyl osobe
    } // ale
    osoba ta i tak nie bedzie jeszcze
    public Osoba modifyOsoba(Osoba person) {
    return manager.merge(person);
    @RolesAllowed({"admin"})
    public void deleteOsoba(Osoba person) {
    person = manager.find(Osoba.class, person.getId());
    manager.remove(person);
    public void deleteRola(Rola rola) {
    rola = manager.find(Rola.class, rola.getId());
    rola.getOsoba().getRole().remove(rola);
    manager.remove(rola);
    DATABASE LISTING :
    -----------------------------------------------------------------+----------\
    --------------------------------------------------------+
    | id | ENTITY_UID | version | rola |
    zatwierdzony | osoba_id | login | RoleGroup |
    -----------------------------------------------------------------+----------\
    --------------------------------------------------------+
    | 1 | | NULL | unregistered |
    | 0 | unregistered | Roles | NULL |
    | 33 | eee91bd9-8c5f-4154-8260-3cac9a18eb97 | 0 | user |
    | 34 | NULL | NULL |
    | 32 | a7ed4e8d-a1ba-473a-921c-73c8f8f89efb | 0 | user |
    | 33 | NULL | NULL |
    -----------------------------------------------------------------+----------\
    --------------------------------------------------------+
    The row numer 1 is added by hand and it works. row number 33 and 32
    are added to database by method CreateUnregisteredOsoba. As you can
    see fields login as well as Roles and RoleGroup are empty (NULL). What
    Im doing wrong ?
    Thanks for your help -
    Roman Kli&#347;
    PS. Table Osoba works fine - everything is added as I want.

    I solved problem.
    The reason why EJB had not added anything to database NULL was becouse wrong names of class. Ive refactored whole class Rola.java to RolaClass.java and suddenly it worked.
    True reason is still unknown but most importent is that it works.
    Thanx for reading topic - hope next time someone will answer my questions.
    By !!

  • Help Needed!! Working with SQL Databases

    Hi All,
    I'm currently working on an application that interfaces with an SQL database, and I seem to have ran into a roadblock.
    I have a multicolumn list box on my front panel which is filled in with data extracted from the database. On selecting any of the rows in the list box, another one is opened displaying another set of data extracted by a generated SQL query. At the moment I am only selecting one row at a time to view it's related data, but I want to expand such that I can select mutiple rows from the list box at a time and see all of their corresponding data.
    With only a single selection, I can pass the index value of the selection to an Index Array Function with the database as the other input and build my SQL statement.
    But with multiple selections, I imagine I would have to build an array on index values and use those as a reference to build the SQL statment. And I am not sure how exactly to go about doing that.
    Here is the code that I currently have working for a single selection from the list box.
    Any help is appreciated. Cheers.
    Solved!
    Go to Solution.

    tdog wrote:
    Hi All,
    I'm currently working on an application that interfaces with an SQL database, and I seem to have ran into a roadblock.
    I have a multicolumn list box on my front panel which is filled in with data extracted from the database. On selecting any of the rows in the list box, another one is opened displaying another set of data extracted by a generated SQL query. At the moment I am only selecting one row at a time to view it's related data, but I want to expand such that I can select mutiple rows from the list box at a time and see all of their corresponding data.
    With only a single selection, I can pass the index value of the selection to an Index Array Function with the database as the other input and build my SQL statement.
    But with multiple selections, I imagine I would have to build an array on index values and use those as a reference to build the SQL statment. And I am not sure how exactly to go about doing that.
    Here is the code that I currently have working for a single selection from the list box.
    Any help is appreciated. Cheers.
    Regarding building the array:
    I can see hat you multicolumn listbox has not multiselection enabled, and is limited to one or zero selected item at once. To enable multiselction; simply rightclick your multicolumn listbox and change your selection mode to support multiple selected items. The NewVal at the event structure should change from a single index number to a 1D array of indexed numbers. No coding needed. Then just retrive out all the items (since you know the indexes) and create the quiry. The quiry part I dont really know (long time no see SQL), but it looks like a for loop to create the string should do the trick?

  • Help - Need to Get Max(Date) from An Unrelated Table in PowerPivot

    I have two tables in my Power Pivot model:
    Table A (a many table)
    Asset    
    SerialNumber                   
    User
    CTUT111                             
    YC112233                                            
    Bob
    CTUT222                             
    ZZ221144                                            
    Susy
    CTUT222                             
    ZZ221144                                            
    Larry
    CTUT333                             
    AB332244                                           
    Bob
    Table B (a many table, a CSV import from another system)
    Asset                    
    SerialNumber                                   
    CheckIn_Date
    CTUT111                             
    YC112233                                            
    6/15/2014
    CTUT111                             
    YC112233                                            
    6/20/2014
    CTUT222                             
    ZZ221144                                            
    6/18/2014
    CTUT333                             
    AB332244                                           
    6/20/2014
    I know it appears odd that Table B would have two entries for the same Asset (CTUT111), but it does.
    I know I could write a SQL query that gave me the MAX(CheckIn_Date), but I’m not staging these datasets in a SQL server first. 
    I’m pulling directly from CSV tables.
    I don’t want to have bridge tables either, if possible. 
    So, I’m left with a many-to-many situation in Power Pivot.
    I want to add a Calculated Column to Table A, called ‘Latest CheckIn Date’ – which I get from Table B, matching on Serial Number.
    So, when I’m done, I would expect the value for Asset=CTUT111 to be 6/20/2014 (since it’s the MAX of a value of dates)
    I’m trying this pattern from Marco Russo in which you don’t need to relate two tables to exchange information, but it doesn’t appear to be working.
    =CALCULATE (
    MAX ( VALUES ( TableB[CheckIn_Date] ) ),
    FILTER (
    TableB,
    'TableA'[SerialNumber]
    = TableB[SerialNumber]
    I’ve also tried to use LOOKUPVALUE, but I can’t seem to figure it out.
    Would appreciate the help.
    Thanks in advance.
    -Eric

    Hi Eric,
    Please, try this one formula:
    =CALCULATE (
                MAXX ( VALUES( TableB[CheckIn_Date] ); TableB[CheckIn_Date] );
                FILTER (
                    TableB;
                    'TableA'[SerialNumber] = TableB[SerialNumber]
    P.S. In my locale I use ";". According to your locale you should use ",".
    Truly yours,
    Paul

Maybe you are looking for

  • Doing catalog work on laptop when away from desktop computer

    I just recently moved from doing all my work on a single machine (laptop, MacBook Pro) connected to a 5 bay external hard drive to using 2 machines, a desktop (Mac Pro) hooked up to the 5 bay eternal HD and the laptop. My set up - Desktop running Sno

  • I am trying to install an new hard drive into my 15-inch, late 2008 MacBook Pro

    I put a new 750Gb Seagate drive in and booted with the Snow Leopard install disk. I held the "C" key down and the disk began to load. An icon of a folder with a question mark flashed. The install process stalled there and I could do no more. I checke

  • Back camera not working

    dear all,, please advice for this issue as i bought a new iPhone 6 128GB space grey from Viva Telecom company in Kuwait, when i started the phone and opened the camera app, the back camera is blur and it not showing us anything but the FaceTime camer

  • IMac G5 (EMC1989) will not start

    I have read several messages, but just cant seem to find my issue. I try to start and the computer (G5 Imac (EMC 1989) gets stuck at the gray screen and progress indicator. I have tried... zapping the pram, reset the PMU, repaired the permissions. I

  • Nokia 5310 - Virus'd

    Hey guys this is my problem I think my phone is virus'd, after putting some songs on today after i tried going onto my menue, turning off my bluetooth, or anything, it keeps crashing, and freezing, i may have a virus on my computer i dont know if tha