Noob help to format date to insert into mysql

Sorry, if this question has been asked before, I did di a search but could not find an answer that I could understand.  I am pretty new to DW and my coding skills are not good so please go easy on me.
I have a simple form to insert records to a mysql database.  I have created a form validarion behaviour to require the fields that are set as not-NULL in the database.  How do I modify the code to allow the date format to be entered in the dob field in the form as DD/MM/YYYY but inserted correctly in the database as YYYY/MM/DD?
Finally, how would I then modify it further to default to todays date?
Here's my code:
<?php require_once('Connections/mypms.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO demographics (title, firstname, surname, dob, address1, address2, town, county, postcode) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['title'], "text"),
                       GetSQLValueString($_POST['firstname'], "text"),
                       GetSQLValueString($_POST['surname'], "text"),
                       GetSQLValueString($_POST['dob'], "date"),
                       GetSQLValueString($_POST['address1'], "text"),
                       GetSQLValueString($_POST['address2'], "text"),
                       GetSQLValueString($_POST['town'], "text"),
                       GetSQLValueString($_POST['county'], "text"),
                       GetSQLValueString($_POST['postcode'], "text"));
  mysql_select_db($database_mypms, $mypms);
  $Result1 = mysql_query($insertSQL, $mypms) or die(mysql_error());
$recordID = mysql_insert_id();
  $insertGoTo = "detail_tab.php?recordID=$recordID";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $insertGoTo));
  exit();
$colname_insert = "1";
if (isset($_GET['recordID'])) {
  $colname_insert = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
mysql_select_db($database_mypms, $mypms);
$query_insert = sprintf("SELECT px_id, title, firstname, surname, dob, address1, address2, town, county, postcode FROM demographics WHERE px_id = %s", $colname_insert);
$insert = mysql_query($query_insert, $mypms) or die(mysql_error());
$row_insert = mysql_fetch_assoc($insert);
$totalRows_insert = mysql_num_rows($insert);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>address</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
//-->
</script>
</head>
<body>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" onSubmit="MM_validateForm('firstname','','R','surname','','R','dob','','R');return document.MM_returnValue">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Title:</td>
      <td><input type="text" name="title" value="" size="32"></td>
      <td> </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Firstname:</td>
      <td><input type="text" name="firstname" value="" size="32"></td>
      <td> </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Surname:</td>
      <td><input type="text" name="surname" value="" size="32"></td>
      <td> </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Dob:</td>
      <td><input type="text" name="dob" value="" size="32"></td>
      <td> </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address1:</td>
      <td><input type="text" name="address1" value="" size="32"></td>
      <td> </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address2:</td>
      <td><input type="text" name="address2" value="" size="32"></td>
      <td> </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Town:</td>
      <td><input type="text" name="town" value="" size="32"></td>
      <td> </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">County:</td>
      <td><input type="text" name="county" value="" size="32"></td>
      <td> </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Postcode:</td>
      <td><input type="text" name="postcode" value="" size="32"></td>
      <td><input name="Search" type="button" id="Search" value="Search"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right"> </td>
      <td><input type="submit" value="Insert record"></td>
      <td> </td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($insert);
?>
Thank you for your help :-)

barrydocks wrote:
thanks for the reply osgood;
I was hoping for a more simple solution than a JQuery date picker, I have read this threat where the SQL queries is aletered:
http://forums.adobe.com/thread/450108
Which I tried but could not make work.
I haven't tried DATE_FORMAT but the example implies that it would work when SELECTING the date from the database to output to a page in a more conventional FORMAT. However you want to INSERT the date using the correct format.
barrydocks wrote:
http://forums.adobe.com/thread/1097555
but I don't know how to use this in my code that already has form validation?
That thread is implying that you would need to convert the date inserted into the form field before it is inserted into the database in the correct format.......so you may as well use a datepicker.
Problem with letting anyone insert a date manually is that a date can be written in many formats which are NOT acceptable by the database. A datepicker overcomes all of these issues. Getting the date back out of the database is a case of simply converting via php into a format which is applicable to your country or your usage OR using the method in the first thread you provided.
Lets see if anyone else can offer a more simple solution for you.

Similar Messages

  • Help with a flash html inserting into DW

    Hello,
    I have created a enquiry section in flash for one of my html DW pages for my site. When I publish the flash doc ti creates a html page (Contact.html). When I open the flash html page in DW or upload it to my server, everything works fine. I recieve an email at my prefered destination etc etc. But as its only a section of my contact page of my website i need to insert it into my site page (get_in_touch.html) soon as i try and take all the stuff from contact.html and insert it into a div in my get_in_touch.html it doesn't respond when the submit button is pressed..... Can someone please help!!!!!
    Dan

    Thanks for all your help. I've managed to sort out the problem, still not
    sure what it was.... My sites live now.
    Just one question for you if you dont mind.
    The page which has the flash on it (yes this one again!) Well if someone
    goes to the page with out having flash player installed on their machine,
    i'm looking for some script to detect that there computer doesn't have
    Flash and redirect them to another html page I've created.
    Would really appreciated any advice you may have.
    many thanks,
    Dan
                                                                                    pziecina                                                 
                 <[email protected]>                                                                               
    To
                 09/09/2009 16:40                Daniel Herrington        
                                                 <[email protected]
                                                 m>                       
                    Please respond to                                       cc
                 clearspace-571537347-50                                  
                 [email protected]                               Subject
                      ums.adobe.com              Help with a
                                                 flash html inserting into DW
                                                                                    Hi
    Somewhere above your tag, you will have a line similar to this - Also in your tag the swf file -
    These are the files that I said may be wrong or missing.
    However if you just edit the flash generated page and include the items you
    require in this, and maintain the same file position, you should have no
    problems,
    PZ

  • Need help for "From concatenate string insert to mysql table"

    Well, most of this problem is a question about SQL syntax. In the VALUES clause you put a comma delimited list of the values to go into the new record. You insert one record at a time. How are the columns defined? Have you done any study on basic SQL?
    Mike...

    i nid to insert values from concatenate string into mysql with using LabSQL, but the result come out from conatenate string is like " 2015-07-08 00:00:00 38.933235E-3" , a logged data of "Date Time Wind Speed(m/s). i nid to put these 3 values into 3 different column in mysql which is Date Time and Wind Speed. How can i pick Date to put inside Date's column, Time into Time's column and Wind Speed into Wind Speed's column in mysql ?
    What i do is
    INSERT INTO wind_speed_data (Date, Time, Wind_Speed) The space in Wind Speed can i put a _ in between Wind Speed? without _ and just put Wind Speed it shows errors.
    VALUES( i have no idea wat to key in at this part ) <--- nid help !
    The Mysql table. Date Time Wind Speed
    The result from concatenate string. Have to insert into mysql.
    My labview program.
    The error i facing.
     

  • Best Practice to fetch SQL Server data and Insert into Oracle Tables

    Hello,
    I want to read sqlserver data everry half an hour and write into oracle tables ( in two different databases). What is the best practice for doing this?
    We do not have any database dblinks from oracle to sqlserver and vice versa.
    Any help is highly appreciable?
    Thanks

    Well, that's easy:
    use a TimerTask to do the following every half an hour:
    - open a connection to sql server
    - open two connections to the oracle databases
    - for each row you read from the sql server, do the inserts into the oracle databases
    - commit
    - close all connections

  • Split data and insert into different rows

    I have a string like 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi,"
    I have created a single column table
    I have to extract data from first untill comma(,) occurs and insert into the table like the following
    sfdsdf
    sfdsf
    sfsd
    qweqeqw
    iuoi
    Please help me how to do it

    Or a Single SQL query
    SELECT trim(',' from DECODE(ROWNUM,1,SUBSTR(STR,1,INSTR(STR,',',1)),
                                        LENGTH(STR)-LENGTH(REPLACE(STR,','))+1,SUBSTR(STR,INSTR(STR,',',-1,1)),
                                         SUBSTR(STR,INSTR(STR,',',1,ROWNUM-1), INSTR(STR,',',1,ROWNUM)-INSTR(STR,',',1,ROWNUM-1))
                                   ))  STR1
                     FROM (SELECT 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi' STR FROM DUAL),ALL_TABLES
                     WHERE ROWNUM <= LENGTH(STR)-LENGTH(REPLACE(STR,','))+1
                      ORDER BY ROWNUM

  • Parse xml data and insert into database

    Hi Friends,
    I have an xml document which needs to be parsed and the data need to be inserted into an oracle database table.
    Please tell me which will be the easiest and optimal way of doing this.
    Thanks,
    Achayan

    Take a look at the JDOM xml parsing library - google for JDOM download or something.
    This will allow you to build an object representation of the XML doc, from which you can then extract the data.
    J

  • Help on Chinese insert into mysql (urgent)

    Dear Friends,
    we are running an coldfusion mx application on window,
    perfect, the database is mysql, utf-8 encoding.
    But when we moved to redhat linux +mysql, the chinese in the
    database displayed as ?????. when we insert into database, the
    chinese inserted like ????? as well...
    Any thing that we missed to config...please help.
    thanks,

    [This page|http://java.sun.com/developer/technicalArticles/Intl/HTTPCharset/] has a good explanation of where the issues might be.
    The thing with character encodings is that you have to get it right at every step. If you miss one of them, then the whole thing blows apart.
    From the minimal info you have here, I would take a look at the request.setCharacterEncoding() methd.
    cheers,
    evnafets

  • Unable to insert into mysql from flash burrito

    I'm having issues inserting a record to mysql, if I use the test "test operation and use these values the it works fine, but now in the android app.
    values in my test operation
        id:0,
        type:"cool",
        navn:"vegar 16"
    the getall method works fine, and shows up on the network monitor, but the button dont work at all, nothing happends in the network monito, if I debug it I can see that the button works, any suggestions on what Im doing wrong?
    code in my view:
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:kunderservice="services.kunderservice.*"
            title="Home">
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
                import valueObjects.Kunder;
                protected function list_creationCompleteHandler(event:FlexEvent):void
                    getAllKunderResult.token = kunderService.getAllKunder();
                protected function button_clickHandler(event:MouseEvent):void
                    var item:Kunder = new Kunder();
                    item.id=0
                    item.navn="vegar"
                    item.type ="test"
                    createKunderResult2.token = kunderService.createKunder(item);
            ]]>
        </fx:Script>
        <fx:Declarations>
            <s:CallResponder id="getAllKunderResult"/>
            <kunderservice:KunderService id="kunderService"/>
            <s:CallResponder id="createKunderResult2"/>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:List id="list" x="35" y="45" width="409" height="193"
                creationComplete="list_creationCompleteHandler(event)" labelField="navn">
            <s:AsyncListView list="{getAllKunderResult.lastResult}"/>
        </s:List>
        <s:Button id="button" x="20" y="406" label="Button" click="button_clickHandler(event)"/>
        </s:View>

    I really appreciate your help. Yes indeed, debugging and seeing what is going on in general is most difficult with flash!
    Once I get this cracked I should be able to complete a lot of what I am trying to achieve.
    After inserting some echo's into my php as such:
    <?php
    $player = $_POST['player'];
    $tournament = $_POST['tournament'];
    $position = $_POST['position'];
    $prize = $_POST['prize'];
    mysql_connect("localhost", "root","poker");
    echo "onnected to database"
    mysql_select_db("poker");
    echo "database connected";
    mysql_query("INSERT INTO results(player,tournament,position,prize) VALUES
    ('$player','$tournamnet','$position','$prize')");
    echo "result added";
    ?>
    The returned info is a load of nonsense to me:
    response from server:  %3C%3Fphp%0A%24player%20=%20%24%5FPOST%5B%27player%27%5D%3B%0A%24tournament%20%3D%20%24%5 FPOST%5B%27tournament%27%5D%3B%0A%24position%20%3D%20%24%5FPOST%5B%27position%27%5D%3B%0A% 24prize%20%3D%20%24%5FPOST%5B%27prize%27%5D%3B%0A%0Amysql%5Fconnect%28%22localhost%22%2C%2 0%22root%22%2C%22poker%22%29%3B%0Aecho%20%22onnected%20to%20database%22%0Amysql%5Fselect%5 Fdb%28%22poker%22%29%3B%0Aecho%20%22database%20connected%22%3B%0Amysql%5Fquery%28%22INSERT %20INTO%20results%28player%2Ctournament%2Cposition%2Cprize%29%20VALUES%20%0A%28%27%24playe r%27%2C%27%24tournamnet%27%2C%27%24position%27%2C%27%24prize%27%29%22%29%3B%0Aecho%20%22re sult%20added%22%3B%0A%3F%3E

  • How to insert into mysql the creation time and modification time from java?

    first how?
    Second what is better from create the date from java or do it from mysql?
    thanks in advace
    Pedro

    One way is to use the GetDate function in mysql. This will set the date as you insert data. insert into table(date) values(getdate())
    Anytime you modifiy the table just call the function again and update its fields.
    Dont know which is beter to do. In java or on the database side.

  • JSP cannot Insert into MYSQL

    hi, i have a jsp code which can successfully return results from MySQL database. But once i change the SQL statement from a select statement to a insert statement, it does not add in a new row in the database. It has no error while compiling but it also appear nothing on the screen when being run. Has the problem got to do with the user privilages of MySQL? thanks.
    //jsp file which parameter posted from another html file. Parameter has been successfully passed.
    <%@ page import="java.sql.*"%>
    <body>
    <%
         String file = request.getParameter("file");
         String pic = request.getParameter("pic");
         ResultSet rs = null;
         ResultSet rs2 = null;
         String timestamp = "CURRENT_TIMESTAMP()";
         String q2 = "Select * from fileReqAce";
         String q1 = "INSERT INTO fileReqAce(PIC,FileName,DateReq) VALUES('"+pic+"','"+file+"',CURRENT_Timestamp())";
    try{
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/wendy?user=user;password=password");
    Statement state = con.createStatement();
         %><br><%
         rs = state.executeQuery(q1);
         //Statement state2 = con.createStatement();
         /**rs2 = state2.executeQuery(q2);
         %><br>
         <table border="1"><%
         while(rs2.next()){
         %>
         <tr>
         <td>Request by : <%=rs2.getString("PIC")%></td><td>File Reference : <%=rs2.getString("FileName")%></td><td>Time Requested : <%=rs2.getTimestamp("DateReq")%></td>
         </tr>
         <%
         %></table>
    <%**/
         rs.close();
    //     rs2.close();
         con.close();
         catch(Exception e)
         System.err.println("Unable to load driver");
         e.printStackTrace();
    %>
    </body>

    That all might be good and well but I think the very important thing to note here is what the first reply stated.
    If you are going to run an Insert sql statement you need to use the executeUpdate() method. You also use this function for Updates and Delete SQL statements.
    Only Select statements that return a recordset use the executeQuery() method. The executeUpdate() method returns an interger that reflects the number of rows affected by the SQL statement.
    Like when you insert 1 row the return value of the executeUpdate method will be one. You can accordingly check this returned value to see if the operation ran successfully. A return value of 0 means that now rows where inserted.
    That is my 2c worth. I hope it helped some.

  • Drop down menu for birthday, inserting into Mysql

    I have a registration form that inserts a new record into
    mysql.
    For the birthday, I have two spryselect dropdowns (month and
    day), and one spry textfield (year).
    Once the user submits the form, how can the selected values
    (month and day) be combined with the inputted year so mysql can
    accept it: YYYY-MM-DD.
    Here is my insert code. I tried concat but I don't think I
    did it right.
    if ((isset($_POST["MM_insert"])) &&
    ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO members (Username,
    Password, `First`, `Last`, Birthday, Address1, Address2, City,
    `State`, Zip, Phone, Email, Newsletter) VALUES (%s, %s, %s, %s, %s,
    %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['Username'], "text"),
    GetSQLValueString($_POST['Password'], "text"),
    GetSQLValueString($_POST['First_Name'], "text"),
    GetSQLValueString($_POST['Last_Name'], "text"),
    GetSQLValueString($_POST['Birthday'], $year.$month.$day),
    GetSQLValueString($_POST['Address1'], "text"),
    GetSQLValueString($_POST['Address2'], "text"),
    GetSQLValueString($_POST['City'], "text"),
    GetSQLValueString($_POST['State'], "text"),
    GetSQLValueString($_POST['Zip'], "int"),
    GetSQLValueString($_POST['Phone_Number'], "int"),
    GetSQLValueString($_POST['EMail_Address'], "text"),
    GetSQLValueString($_POST['Newsletter'], "text"));

    chris.cavage wrote:
    > Here is my insert code. I tried concat but I don't think
    I did it right.
    Assuming you have named the select elements and text field
    "month",
    "day", and "year", you need to add this somewhere near the
    top of the page:
    if (isset($_POST['month']) && isset($_POST['day'])
    isset($_POST['year'])) {
    $_POST['birthday'] =
    "{$_POST['year']}-{$_POST['month']}-{$_POST['day']}";
    } else {
    $_POST['birthday'] = 0;
    Then change this:
    > GetSQLValueString($_POST['Birthday'],
    > $year.$month.$day),
    to this:
    GetSQLValueString($_POST['Birthday'], "text"),
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions"
    http://foundationphp.com/

  • Need help in storing data from JList into a vector

    need help in doing the following.-
    alright i click a skill on industryskills Jlist and press the add button and it'll be added to the applicantskills Jlist. how do i further store this data that i added onto the applicantskills JList into a vector.
    here are the codes:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.text.*;
    import java.util.*;
    import java.util.Vector;
    import javax.swing.JScrollPane.*;
    //import javax.swing.event.ListSelectionListener;
    public class Employment extends JFrame
            //declare class variables
            private JPanel jpApplicant, jpEverything,jpWEST, jpCENTRE, jpEAST, jpAddEditDelete,
                                       jpCentreTOP, jpCentreBOT, jpEastTOP, jpEastCENTRE, jpEastBOT,
                                       jpBlank1, panel1, panel2, panel3, panel4,jpBottomArea,
                                       jpEmptyPanelForDisplayPurposes;
            private JLabel jlblApplicantForm, jlblAppList, jlblName, jlblPhone,
                                       jlblCurrentSalary, jlblPassword, jlblDesiredSalary,
                                       jlblNotes, jlblApplicantSkills, jlblIndustrySkills,
                                       jlblBlank1, jlblBlank2, ApplicantListLabel,
                                       NotesListLabel, ApplicantSkillsLabel,
                                       IndustrySkillsLabel,jlblEmptyLabelForDisplayPurposes;  
            private JButton jbtnAdd1, jbtnEdit, jbtnDelete, jbtnSave, jbtnCancel,
                                            jbtnAdd2, jbtnRemove;
            private JTextField jtfName, jtfPhone, jtfCurrentSalary, jtfPassword,
                                               jtfDesiredSalary;
              private JTabbedPane tabbedPane;
            private DefaultListModel /*listModel,*/listModel2;
              String name,password,phone,currentsalary,desiredsalary,textareastuff,NotesText;
              String selectedname;
            final JTextArea Noteslist= new JTextArea();;
            DefaultListModel listModel = new DefaultListModel();
            JList ApplicantSkillsList = new JList(listModel);
           private ListSelectionModel listSelectionModel;
            JList ApplicantList, /*ApplicantSkillsList,*/ IndustrySkillsList;
            //protected JTextArea NotesList;    
                    //Vector details = new Vector();
                  Vector<StoringData> details = new Vector<StoringData>();             
                public static void main(String []args)
                    Employment f = new Employment();
                    f.setVisible(true);
                    f.setDefaultCloseOperation(EXIT_ON_CLOSE);
                    f.setResizable(false);
                }//end of main
                    public Employment()
                            setSize(800,470);
                            setTitle("E-commerce Placement Agency");
                                  Font listfonts = new Font("TimesRoman", Font.BOLD, 12);
                            JPanel topPanel = new JPanel();
                            topPanel.setLayout( new BorderLayout() );
                            getContentPane().add( topPanel );
                            createPage1();
                            createPage2();
                            createPage3();
                            createPage4();
                            tabbedPane = new JTabbedPane();
                            tabbedPane.addTab( "Applicant", panel1 );
                            tabbedPane.addTab( "Job Order", panel2 );
                            tabbedPane.addTab( "Skill", panel3 );
                            tabbedPane.addTab( "Company", panel4 );
                            topPanel.add( tabbedPane, BorderLayout.CENTER );
            public void createPage1()//PAGE 1
                 /*******************TOP PART********************/
                            panel1 = new JPanel();
                            panel1.setLayout( new BorderLayout());
                                  jpBottomArea = new JPanel();
                                  jpBottomArea.setLayout(new BorderLayout());
                            jpApplicant= new JPanel();
                            jpApplicant.setLayout(new BorderLayout());
                            Font bigFont = new Font("TimesRoman", Font.BOLD,24);
                            jpApplicant.setBackground(Color.lightGray);
                            jlblApplicantForm = new JLabel("\t\t\t\tAPPLICANT FORM  ");
                            jlblApplicantForm.setFont(bigFont);
                            jpApplicant.add(jlblApplicantForm,BorderLayout.EAST);
                            panel1.add(jpApplicant,BorderLayout.NORTH);
                            panel1.add(jpBottomArea,BorderLayout.CENTER);
           /********************************EMPTY PANEL FOR DISPLAY PURPOSES*************************/
                               jpEmptyPanelForDisplayPurposes = new JPanel();
                               jlblEmptyLabelForDisplayPurposes = new JLabel(" ");
                               jpEmptyPanelForDisplayPurposes.add(jlblEmptyLabelForDisplayPurposes);
                               jpBottomArea.add(jpEmptyPanelForDisplayPurposes,BorderLayout.NORTH);
           /*****************************************WEST*********************************/             
                            jpWEST = new JPanel();                 
                            jpWEST.setLayout( new BorderLayout());
                            //Applicant List
                                  listModel2=new DefaultListModel();
                                  ApplicantList = new JList(listModel2);
                                listSelectionModel = ApplicantList.getSelectionModel();
                                listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
                                JScrollPane scrollPane3 = new JScrollPane(ApplicantList);
                                  ApplicantList.setPreferredSize(new Dimension(20,40));
                                 scrollPane3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);                                             
                                scrollPane3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                            ApplicantListLabel = new JLabel( "Applicant List:");
                            jpWEST.add(ApplicantListLabel,"North"); 
                            jpWEST.add(scrollPane3,"Center");
                            jpBottomArea.add(jpWEST,BorderLayout.WEST);
                            /*********CENTRE*********/
                            jpCENTRE = new JPanel();
                            jpCENTRE.setLayout(new GridLayout(2,1));
                            jpCentreTOP = new JPanel();
                            jpBottomArea.add(jpCENTRE,BorderLayout.CENTER);
                            jpCENTRE.add(jpCentreTOP);
                            jpCentreTOP.setLayout(new GridLayout(6,2));
                              //Creating labels and textfields
                            jlblName = new JLabel( "Name:");
                            jlblBlank1 = new JLabel ("");
                            jtfName = new JTextField(18);
                            jlblBlank2 = new JLabel("");
                            jlblPhone = new JLabel("Phone:");
                            jlblCurrentSalary = new JLabel("Current Salary:");
                            jtfPhone = new JTextField(13);
                            jtfCurrentSalary = new JTextField(7);
                            jlblPassword = new JLabel("Password:");
                            jlblDesiredSalary = new JLabel("Desired Salary:");
                            jtfPassword = new JTextField(13);
                            jtfDesiredSalary = new JTextField(6);
                              //Add labels and textfields to panel
                            jpCentreTOP.add(jlblName);
                            jpCentreTOP.add(jlblBlank1);
                            jpCentreTOP.add(jtfName);
                            jpCentreTOP.add(jlblBlank2);
                            jpCentreTOP.add(jlblPhone);
                            jpCentreTOP.add(jlblCurrentSalary);
                            jpCentreTOP.add(jtfPhone);
                            jpCentreTOP.add(jtfCurrentSalary);
                            jpCentreTOP.add(jlblPassword);
                            jpCentreTOP.add(jlblDesiredSalary);
                            jpCentreTOP.add(jtfPassword);
                            jpCentreTOP.add(jtfDesiredSalary);
                            //Noteslist
                            jpCentreBOT = new JPanel();
                            jpCentreBOT.setLayout( new BorderLayout());
                            jpCENTRE.add(jpCentreBOT);
                            jpBlank1 = new JPanel();
                             //     Noteslist = new JTextArea(/*Document doc*/);
                            JScrollPane scroll3=new JScrollPane(Noteslist);
                                scroll3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);                                             
                                scroll3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                            NotesListLabel = new JLabel( "Notes:");
                            jpCentreBOT.add(NotesListLabel,"North"); 
                            jpCentreBOT.add(scroll3,"Center");
                            jpCentreBOT.add(jpBlank1,"South");
                            jpBottomArea.add(jpCENTRE,BorderLayout.CENTER);
                            /**********EAST**********/
                            //Applicant Skills Panel
                            //EAST ==> TOP
                            jpEAST = new JPanel();
                            jpEAST.setLayout( new BorderLayout());
                            jpEastTOP = new JPanel();
                            jpEastTOP.setLayout( new BorderLayout());
                            ApplicantSkillsLabel = new JLabel( "Applicant Skills");
                            JScrollPane scrollPane1 = new JScrollPane(ApplicantSkillsList);
                               scrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);                                             
                              scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);                                             
                            ApplicantSkillsList.setVisibleRowCount(6);
                            jpEastTOP.add(ApplicantSkillsLabel,"North"); 
                            jpEastTOP.add(scrollPane1,"Center");
                            jpEAST.add(jpEastTOP,BorderLayout.NORTH);
                            jpBottomArea.add(jpEAST,BorderLayout.EAST);
                            //Add & Remove Buttons
                            //EAST ==> CENTRE
                            jpEastCENTRE = new JPanel();
                            jpEAST.add(jpEastCENTRE,BorderLayout.CENTER);
                            jbtnAdd2 = new JButton("Add");
                            jbtnRemove = new JButton("Remove");
                            //add buttons to panel
                            jpEastCENTRE.add(jbtnAdd2);
                            jpEastCENTRE.add(jbtnRemove);
                            //add listener to button
                           jbtnAdd2.addActionListener(new Add2Listener());
                           jbtnRemove.addActionListener(new RemoveListener());
                            //Industry Skills Panel
                            //EAST ==> BOTTOM
                            jpEastBOT = new JPanel();
                            jpEastBOT.setLayout( new BorderLayout());
                           String[] data = {"Access97", "Basic Programming",
                           "C++ Programming", "COBOL Programming",
                           "DB Design", "Fortran programming"};
                           IndustrySkillsList = new JList(data);
                           JScrollPane scrollPane = new JScrollPane(IndustrySkillsList);
                           scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);                                             
                           scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                           IndustrySkillsLabel = new JLabel( "Industry Skills:");
                           jpEastBOT.add(IndustrySkillsLabel,"North"); 
                           jpEastBOT.add(scrollPane,"Center");
                           jpEAST.add(jpEastBOT,BorderLayout.SOUTH);
                            //BOTTOM
                            jpAddEditDelete= new JPanel();
                            jbtnAdd1=       new JButton("Add");
                            jbtnEdit=       new JButton("Edit");
                            jbtnDelete=     new JButton("Delete");
                            jbtnSave=       new JButton("Save");
                            jbtnCancel=     new JButton("Cancel");
                            jpAddEditDelete.add(jbtnAdd1);
                            jpAddEditDelete.add(jbtnEdit);
                            jpAddEditDelete.add(jbtnDelete);
                            jpAddEditDelete.add(jbtnSave);
                            jpAddEditDelete.add(jbtnCancel);
                               jbtnEdit.addActionListener(new EditListener());
                               jbtnDelete.addActionListener(new DeleteListener());
                                jbtnEdit.addActionListener(new EditListener());
                            jbtnAdd1.addActionListener(new Add1Listener());
                            jbtnCancel.addActionListener(new CancelListener());
                            jpBottomArea.add(jpAddEditDelete,BorderLayout.SOUTH);
            public void createPage2()//PAGE 2
                    panel2 = new JPanel();
                    panel2.setLayout( new GridLayout(1,1) );
                    panel2.add( new JLabel( "Sorry,under construction" ) );
            public void createPage3()//PAGE 3
                    panel3 = new JPanel();
                    panel3.setLayout( new GridLayout( 1, 1 ) );
                    panel3.add( new JLabel( "Sorry,under construction" ) );
            public void createPage4()//PAGE 4
                    panel4 = new JPanel();
                    panel4.setLayout( new GridLayout( 1, 1 ) );
                    panel4.add( new JLabel( "Sorry,under construction" ) );
            public class Add1Listener implements ActionListener
            public void actionPerformed(ActionEvent e)
                    name = jtfName.getText();
                    password = jtfPassword.getText();
                    phone = jtfPhone.getText();
                    currentsalary = jtfCurrentSalary.getText();
                    int i= Integer.parseInt(currentsalary);
                    desiredsalary = jtfDesiredSalary.getText();
                    int j= Integer.parseInt(desiredsalary);
                       StoringData person = new StoringData(name,password,phone,i,j);
                   //     StoringData AppSkillsList = new StoringData(listModel);
                    details.add(person);
                 //     details.add(AppSkillsList);
                  listModel2.addElement(name);
                    jtfName.setText("");
                    jtfPassword.setText("");
                    jtfPhone.setText("");
                    jtfCurrentSalary.setText("");
                    jtfDesiredSalary.setText("");
    //                NotesList.setText("");
            public class Add2Listener implements ActionListener
                    public void actionPerformed(ActionEvent e)
                           String temp1;
                           temp1 = (String)IndustrySkillsList.getSelectedValue();
                           listModel.addElement(temp1);
            public class RemoveListener implements ActionListener
                    public void actionPerformed(ActionEvent e)
                            int index = ApplicantSkillsList.getSelectedIndex();
                                listModel.remove(index);
            public class EditListener implements ActionListener
                    public void actionPerformed(ActionEvent e)
                            jtfName.setEditable(true);
                            jtfPassword.setEditable(true);
                            jtfPhone.setEditable(true);
                            jtfCurrentSalary.setEditable(true);
                            jtfDesiredSalary.setEditable(true);
                            Noteslist.setEditable(true);
                            jbtnAdd2.setEnabled(true);               
                            jbtnRemove.setEnabled(true);
                            jbtnSave.setEnabled(true);
                            jbtnCancel.setEnabled(true);                     
            public class DeleteListener implements ActionListener
                    public void actionPerformed(ActionEvent e)
                        int index1 = ApplicantList.getSelectedIndex();
                            listModel2.remove(index1);
            public class SaveListener implements ActionListener
                    public void actionPerformed(ActionEvent e)
            public class CancelListener implements ActionListener
                    public void actionPerformed(ActionEvent e)
                    jtfName.setText("");
                    jtfPassword.setText("");
                    jtfPhone.setText("");
                    jtfCurrentSalary.setText("");
                    jtfDesiredSalary.setText("");                         
            public class SharedListSelectionHandler implements ListSelectionListener
            public void valueChanged(ListSelectionEvent e)
             selectedname =ApplicantList.getSelectedValue().toString();
             StoringData selectedPerson = null;
             jtfName.setEditable(false);
             jtfPassword.setEditable(false);
             jtfPhone.setEditable(false);
             jtfCurrentSalary.setEditable(false);
             jtfDesiredSalary.setEditable(false);                                 
             Noteslist.setEditable(false);
             jbtnAdd2.setEnabled(false);               
             jbtnRemove.setEnabled(false);
             jbtnSave.setEnabled(false);
             jbtnCancel.setEnabled(false);
                   for (StoringData person : details)
                          if (person.getName1().equals(selectedname))
                                 selectedPerson = person;
                                 jtfName.setText(person.getName1());
                                 jtfPassword.setText(person.getPassword1());
                              jtfPhone.setText(person.getPhone1());
                              //String sal1 = Integer.parseString(currentsalary);
                             // String sal2 = Integer.parseString(desiredsalary);
                             // jtfCurrentSalary.setText(sal1);
                             // jtfDesiredSalary.setText(sal2);
                                 break;
                   //     if (selectedPerson != null)
    }

    Quit posting 300 line programs to ask a question. We don't care about your entire application. We only care about code that demonstrates your current problem. We don't want to read through 300 lines to try and find the line of code that is causing the problem.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.
    Here is a simple SSCCE. Now make your changes and if you still have problems you have something simple to post. If it works then you add it to your real application.
    Learn to simplify your problem by simplifying the code.
    import java.awt.*;
    import javax.swing.*;
    public class ListTest2 extends JFrame
         JList list;
         public ListTest2()
              String[] numbers = { "one", "two", "three", "four", "five", "six", "seven" };
              list = new JList( numbers );
              JScrollPane scrollPane = new JScrollPane( list );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              ListTest2 frame = new ListTest2();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(200, 200);
              frame.setLocationRelativeTo( null );
              frame.setVisible( true );
    }

  • Read XML data and Insert into SQL Database

    Hi Everybody,
    i am new to Oracle SOA.
    Can anybody help me out to how to insert xml data into sql server using BPEL and JDeveloper (with clear steps).
    thanks in advance
    Vishnu Kumar

    Hi Peter,
    you are right,at high level i was able to figure at these things.
    But i don't know how to implement it using jdeveloper.
    It will be more helpful if you can give me detailed steps to do it.
    Thanks
    Vishnu Kumar

  • Need help to format data

    Hi Gurus,
    I am extracting the field "CATEGORY" from oracle to BW. But I found data in the InfoCube is in exponential format (Example Cateory = 4.1030000000000000E+03 ). I don't need data in exponential format. What's the best way to fix this problem.
    Thanks
    Liza

    Hi,
    Check the downloaded file from Oracle. I guess, you opened up in Excel and then loaded into BW.
    Open it in Notepad and suppose you are creating .csv file, then open it as text file in the Excel.
    Hope, it helps.
    Thanks
    Viswa

  • Data not inserted into database from jsf..

    hello..
    m developing ma project with 2 separate module-EJB and WEB .in which web module contains JSF managed bean and jsf-jsp pages.
    my application is running well.bt didn't give output to the database for inserting data.
    m giving ma simple test application ...plz tell me whr m going wrong.
    //Emp.java---entity file in ejb module
    package entity;
    import java.io.Serializable;
    import javax.persistence.Basic;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.Table;
    @Entity
    @Table(name = "emp")
    @NamedQueries({
        @NamedQuery(name = "Emp.findAll", query = "SELECT e FROM Emp e"),
        @NamedQuery(name = "Emp.findByName", query = "SELECT e FROM Emp e WHERE e.name = :name"),
        @NamedQuery(name = "Emp.findByAddress", query = "SELECT e FROM Emp e WHERE e.address = :address")})
    public class Emp implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @Basic(optional = false)
        @Column(name = "name")
        private String name;
        @Column(name = "address")
        private String address;
        public Emp() {
        public Emp(String name) {
            this.name = name;
        public Emp(String name, String address) {
            this.name = name;
            this.address = address;
        public String getName() {
            return name;
        public void setName(String name) {
            this.name = name;
        public String getAddress() {
            return address;
        public void setAddress(String address) {
            this.address = address;
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (name != null ? name.hashCode() : 0);
            return hash;
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof Emp)) {
                return false;
            Emp other = (Emp) object;
            if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))) {
                return false;
            return true;
        @Override
        public String toString() {
            return "entity.Emp[name=" + name + "]";
    //empsession.java--session file in ejb module
    package session;
    import entity.*;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    @Stateless
    public class empsession implements empsessionRemote {
        @PersistenceContext(unitName = "EJBmodulePU")
        private EntityManager em;
        public void addemp(String name, String address) {
            Emp objemp=new Emp(name,address);
            em.persist(objemp);
    //empsessionRemote.java--remote file for sessionbean
    package session;
    import javax.ejb.Remote;
    @Remote
    public interface empsessionRemote {
        void addemp(String name, String address); 
    //empMB.java--managed bean file in web module
    package mbean;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.RequestScoped;
    import javax.naming.InitialContext;
    import session.empsessionRemote;
    @ManagedBean(name="empMB")
    @RequestScoped
    public class empMB {
        private String name;
        private String address;
        public String getAddress() {
            return address;
        public void setAddress(String address) {
            this.address = address;
        public String getName() {
            return name;
        public void setName(String name) {
            this.name = name;
        /** Creates a new instance of empMB */
        public empMB() {
        public void empadd()
            try
            InitialContext ic = new InitialContext();
            empsessionRemote esr=(empsessionRemote)ic.lookup(empsessionRemote.class.getName());
            esr.addemp(name, address);
            catch(Exception ex)
    }//AddEmp.jsp --jsf page in web module
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <f:view>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>JSP Page</title>
    </head>
    <body>
    name:
    <h:inputText id="txt1" value="#{empMB.name}"></h:inputText>
    address:
    <h:inputText id="txt2" value="#{empMB.address}"></h:inputText>
    <h:commandButton id="btnadd" value="submit" action="#{empMB.empadd}"></h:commandButton>
    <h1><h:outputText value="Hello World!"/></h1>
    </body>
    </html>
    </f:view>
    //faces-config.xml
    <faces-config version="2.0"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
    <managed-bean>
    <managed-bean-name>empMB</managed-bean-name>
    <managed-bean-class>mbean.empMB</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
    <from-view-id>/AddEmp.jsp</from-view-id>
    <navigation-case>
    <from-outcome>AddEmp</from-outcome>
    <to-view-id>/index.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    m using toplink provider and mysql db
    wating for positive reply..
    thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I think this question would be more appropriate in a forum devoted to database or JPA topics.

Maybe you are looking for

  • IWeb'08 Photo's

    I wish I could give a solution to this problem, but I simply don't have one. What I have discovered is that it appears that my iweb domain file became corrupt some how during the upgrade. It was fine prior to upgrading but afterwards, no images appea

  • Broken glass

    broken glass how much will it cost me to replace broken glass

  • Warning when running FBICR3

    Hi When running FBICR3 I get this warning Display categories open items and recivables contain some of the same data records Message no. FB_Rc017. If is only a warning and the reports is correct, but the warning is irretating....how can I avoid the w

  • F90 -fast error

    My system is Red hat enterprise 5, and my CPU is X5667, memeory is 48G. When I install Sunstudio update 1 on my system, I use f90 with the option of '-fast'. i usually use f90 as 'f90 -g -fast -xautopar *.f90'. '-g' and '-autopar' is ok for my system

  • Isight say I did not respond when I establish the video call...pls help

    Good day. When I request a video call to my son, ichat begins the call, gives the message that waiting for "name" to respond then states starting video call with "Name" then fails stating that I did not respond. Any ideas? Thx tons