Database Mysql

Hello everybody. I hava a problem, I need to access a Mysql Database from midlet. How Can I do it?
Thanks.

cann't I edit my words?nope ;-) I hate this sometimes too ...
To the topic: clapton is right. you need something like a proxy that does the DB-Stuff for your mobile. There you can choose between a simple apache using php, a tomcat for servlets, apache with JServ or some J2EE Beans or something...
Kay

Similar Messages

  • JTable and Database (mysql)

    Does anyone know or have codes on how to get value from JTable cells and it will store into database (mysql).

    You will have to extract the values for each column within the row and then construct an INSERT statement with the column names/values (or simply values if all columns)
    If the row already exists and you want to update it, you will have to write an UPDATE stmt.
    I don't have the code at hand, but will post it if I find it

  • What should i do with an Oracle 11g Database, MySQL database and a dump file.

    I just joining to a new work field, almost about a database and i know "NOTHING" about this field.
    My company has a system that running by Oracle Database, the problem is that Oracle Database will cost a lot of money when my company expands.
    So the quest is converting Oracle Database to MySQL database.
    Of course i cant try to convert it in the main Database, so i create one Oracle 11g Database on my LocalHost, and it already actived in " Localhost:1158 " etc.
    I have another Sever test that already set up MySQL database, and a dump file from the system.
    So I want to ask these 2 questions :
    1. How to create an new Oracle Database from that dump file ?
    2. Is it alright if i use tool to convert Oracle Database into MySql, or i should do it manually ?
    Thanks alot.

    I just joining to a new work field, almost about a database and i know "NOTHING" about this field.
    My company has a system that running by Oracle Database, the problem is that Oracle Database will cost a lot of money when my company expands.
    So the quest is converting Oracle Database to MySQL database.
    I predict that converting to MySQL will cost your company more as it expands. As you expand managing contention becomes more important - Oracle does this for you. I do not think MySQL does, so you'll have to write more code to deal with this, costing the company money. A big part of making application scalable and reliable is to use stored procedures, how good are MySQL's compared to PL/SQL's. What other features are there that MySQL has that will benefit your company that Oracle doesn't. What do you need to think about as your company expands that need to be taken care of in the database. I would have thought a migration from MySQL to Oracle would be more common to deal with expansion.
    As you know "NOTHING" you need to think about what each database can give you for the next 10 years to cope with you businesses potential requirements, and extimate how much it will cost to implement these requirements, then make the decision

  • Java feat database(MySql)

    I am trying to write a single-client/server application which maintains a database. The client app sends request to server which executes the request and returns the result to the client. The GUI on the client side must be able manipulate the database by: creating tables, load tables with the serialized files, insert data, delete data, manipulate Booleans’ and do calculations.
    Question 1: In my class how do I initialize the Boolean? Referring to the text book (JAVA Sixth Edition) Chapter 14, I created the class and a different class with the same info except for the import of the Serializable class/(function) in a package that I created. Both classes are in there.
    Problem 1: How do I declare the default constructor of a Boolean? For numeric and string value it seems easy e.g.:
    public class Serializable()
    this(0," "," ",0.0);
    But for a Boolean?
    public class Serializable()
    this(" "," ", ?); - >string, string, Boolean
    I have made compensation for handling a ClassNotFoundException, but that error message is about all it gives me. Where did I go wrong????
    Problem 2:How do I code the other functionalities? The book only talks about viewing information from the database, nothing about creating and loading tables
    let alone insert and delete.
    It does talk about a script that is on the CD to create the tables in MySql, but I don't have the CD. Can I use such a script in my client app?
    Are there some examples of such applications on the net or are there scripts I can refer to, that might help me?
    Please help :-{
    Thanx
    Sgt

    This is what my record is suppose to look like:
    package DvdPackage;
    import java.io.Serializable;
    public class Movies implements Serializable
    private String title;
    private String category;
    private boolean newRelease;
    private boolean availableForRent;
    public Movies()
    this("","",true,true);
    public Movies(String Title, String Cat, boolean New, boolean Avail)
    setTitle(Title);
    setCategory(Cat);
    setRelease(New);
    setAvailable(Avail);
    // set methods
    public void setTitle(String Title)
    title = Title;
    public void setCategory(String Cat)
    category = Cat;
    public void setRelease(boolean New)
    newRelease = New;
    public void setAvailable(boolean Avail)
    availableForRent = Avail;
    //get methods
    public String getTitle()
    return title;
    public String getCat()
    return category;
    //checks if the movie is a new release
    public boolean getNew()
    return newRelease;
    //checks if the movie is available
    public boolean getAvail()
    return availableForRent;
    The reading a serialized class looks like this:
    import java.io.*;
    import DvdPackage.Movies;
    public class ReadingFiles
    private ObjectInputStream input;
    public void openFile()
    try
    input = new ObjectInputStream(new FileInputStream("Movies.ser"));
    catch(IOException ioException)
    System.err.println("Error opening the files.");
    public void readRecords()
    Movies record;
    //System.out.printf("%-40%-40%-10s%10\n", "Title", "Category","New Release","Available");
    try
    while(true)
    record = (Movies) input.readObject();
    System.out.printf("%-20%-20%-1s%1\n",
    record.getTitle(),
    record.getCat(),
    record.getNew(),
    record.getAvail());
    catch(EOFException eofException)
    return;
    catch(ClassNotFoundException classNotFound)
    System.out.println("Unable to create object.");
    catch(IOException ioException)
    System.out.println("Error during the read of the Movies file!!!!");
    public void closeFile()
    try
    if(input != null)
    input.close();
    catch(IOException ioException)
    System.err.println("Error closing movie File!!!!");
    System.exit(1);
    The code runs with no errors, but it stops at the "ClassNotFound" handler.
    What is wrong with my code?

  • Calling Stored Procedures from a database ( MySQL )

    Hello, I've been trying to get my stored procedures to work for more than a week now, I am able to connect to my database, register the output, but when it get's to the execute query line, the try statement drops out. Any Ideas, I tried using a resultset earlier, but have created a single value returning stored proc now.
    public static String sp01() {
            String returnedID2="21345";
            String returnedID="1";
            int rtid;
            try {
                Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/corrovu?user=root&password=Glancino");        
                CallableStatement cStmt = conn.prepareCall("{? = call sp3()}");
                returnedID="2"; //2 is returned
                cStmt.registerOutParameter(1, java.sql.Types.INTEGER);
                returnedID="3"; //3 is returned
                cStmt.execute();
                returnedID="4"; //4 fails to return !!!!
                rtid = cStmt.getInt(1);
                returnedID="5";
                if (returnedID == null){
                    return null;
                } else {
                    return returnedID;
            } catch(Exception e){
            return returnedID; //Note I had to insert this line to get the method working
        }If I type CALL sp3(); in the query editor, it returns '4' which is the value in the database.
    I don't know why it dies on the cStmt.execute(); Am I not pereparing the call correctly? I tried "? = CALL sp3();" as well to no avail.
    Thanks, looking forward to the replies, Once I have got this working, I will write up the correct methods to access stored procs's from MySQL.

    Thank you for the fast replies, I have seen these examples before and tried them, this metod is still crashing out when it hit's the execute() command. If you open a new project, insert a button, called button1, insert 2 text boxes called, txt1 & txt2, open up the java and insert this code in the relevent spots. To see where it fails, include the returnedID lines i've included in the comment lines.
    The stored procedure is simple, it just seraches a string and returns a single integer.
    DELIMITER $$;
    DROP PROCEDURE IF EXISTS `corrovu`.`sp3`$$
    CREATE PROCEDURE `sp3`()
    BEGIN
         SELECT diam FROM details WHERE PID = '0050003';
    END$$
    DELIMITER ;$$
    diam is '4' where PID is '0050003' so the txt1 should display 4 but it doesn't, this is really driving me crazy, I've probably spent more than 50 hours trying to get the stored proc working, I don't know what more to do. I've looked at hundreds of expamples and can't get any of them working.
    package spca;
    import com.sun.rave.web.ui.appbase.AbstractPageBean;
    import com.sun.rave.web.ui.component.Body;
    import com.sun.rave.web.ui.component.Form;
    import com.sun.rave.web.ui.component.Head;
    import com.sun.rave.web.ui.component.Html;
    import com.sun.rave.web.ui.component.Link;
    import com.sun.rave.web.ui.component.Page;
    import javax.faces.FacesException;
    import com.sun.rave.web.ui.component.Button;
    import com.sun.rave.web.ui.component.StaticText;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.CallableStatement;
    import java.sql.ResultSet;
    import java.sql.Types;
    public class Page1 extends AbstractPageBean {
        static int outputValue = 69;
        public static String sp01() {
            String returnedID2="21345";
            String returnedID="1";
            try {
                //The following line loads the driver (it work's to see include - returnedID="2";)
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                //This line connects to the database (it work's )- returnedID="3";
                Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/corrovu?user=root&password=Glancino");
                //This line prepares the call (apparantly work's, If i put a non-existant stored proc, this line fails)- returnedID="4";
                CallableStatement cStmt = conn.prepareCall("{?= call sp3()}");
                //This line registers the out paramaters (it apperntly works, If I insert incorrect values, it fails)- returnedID="5";
                cStmt.registerOutParameter(1, Types.INTEGER);
                //This line exit's the Try, I changed it as per the example, it still fails. I don't know what I'm doing wrong.- returnedID="6";
                boolean hadResults = cStmt.execute();
                //The rest of the code doesn't get parsed - returnedID="7";
                while (hadResults) {
                    ResultSet rs = cStmt.getResultSet();
                    hadResults = cStmt.getMoreResults();
                outputValue = cStmt.getInt(1); // index-based
                if (returnedID == null){
                    return null;
                } else {
                    return returnedID;
            } catch(Exception e){
            //I had to insert this following line to make this method work, this was not in the example as per these forums???
            return returnedID;
        public String button1_action() {
            txt1.setText(sp01());
            txt2.setText(""+outputValue);      
            return null;
    }Cheers, I hope someone can help me.

  • Database (MySQL) connection error

    Can someone please tell me what I have to do to either the MySQL database or the code in order for this to work? The app will not connect to the database. The URL is correct, I have pasted the errors. Thanks so much for the help. I know errors arent code but that's the only way I could exceed the 5000 limit.
    init: deps-jar: Compiling 3 source files to C:\Users\pberardi\Documents\901A\IT494\Code Drop\HTTI2.zip\HTTI2\build\classes Note: C:\Users\pberardi\Documents\901A\IT494\Code Drop\HTTI2.zip\HTTI2\src\htti2\RowSorterToStringConverter.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. compile: run: [TopLink Info]: 2009.01.21 01:40:38.221--ServerSession(25488452)--TopLink, version: Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007)) Jan 21, 2009 1:40:38 PM org.jdesktop.application.Application$1 run SEVERE: Application class htti2.HTTI2App failed to launch Local Exception Stack: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) Error Code: 1045         at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305)         at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:102)         at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184)         at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)         at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)         at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)         at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:120)         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:91)         at htti2.EmpInfoView.initComponents(EmpInfoView.java:402)         at htti2.EmpInfoView.<init>(EmpInfoView.java:40)         at htti2.HTTI2App.startup(HTTI2App.java:19)         at org.jdesktop.application.Application$1.run(Application.java:171)         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)         at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Edited by: pberardi1 on Jan 22, 2009 6:41 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    pberardi1 wrote:
    Internal Exception: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
    Error Code: 1045This suggests that you are trying to connect to the database with wrong/no password,
    Try and see if you can connect to your server with a statement like,
    mysql -uroot -p<password>Hope you find more relevant material here

  • Newbie to databases: mysql, sql and jdbc?

    hi,
    am new to databases and java-database access and was wondering if the following is correct
    1) sql is a standard
    2) mysql is an implementation of sql
    3) there is a jdbc sql driver that can access any sql database (including mysql)
    any help appreciated,
    asjf

    Pretty much yes that's true.ah, so its a defacto standard? I should've said "specification" above - in the same way that j2ee is a specification, and different vendors offer different implementations?
    it sounds like SQL is not like j2ee in that way?
    Most of the SQL compliant databases provide a JDBC driver that you can use. You can even write your own if you have an urge to do so.does JDBC provide a backend independent way of accessing databases? ie you can swap the drivers around fairly freely?
    also, i'm having trouble locating a high-level overview of jdbc - i've found the "Basic tutorial" but this is more of a low-level step-by-step guide to starting out
    http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html
    thanks,
    asjf

  • Connect database(Mysql) using Ejb3.0

    Hi All,
    Can any one give me an step by step procedure for entity beans it refers the mysql database's student table
    thanks & regards,
    Maheshwaran Devaraj

    There's more that code involved. First off you need an implementation of the JPA (Java persistence API). Probably hibernate or toplink. The appropriate libraries have to go into your project (most of them can be runtime only but you need a library defining the JPA interfaces.).
    You need a resource file called persistence.xml in the META-INF directory of your class tree or jar. That defines things like the database connection details, a list of entity classes and a set of options.
    If you use an up to date IDE it will probably do most of this for you. Once it's set up you get an EntityManagerFactory instance and, from that, you get an EntityManager for each session from which you search for and otherwise manipulate entities. Generally you don't have to write any actual SQL, though you will probably have to write queries in a modified language called JPQL (Java Persistence Query Language).

  • Help Me - Database Mysql Xampp Java FX 2.0

    Hello every one. Please Help me, i was search site by site was'nt found my solucition.
    I was created project database Java Fx 2 with Mysql Xampp
    I have 5 class :
    Login.java
    Insert.java
    Select.java
    Insert.java
    Update.java
    Delete.java
    Thank you for help me.
    Edited by: 912711 on Feb 6, 2012 5:50 PM

    Update.java
    import javafx.application.*;
    import javafx.beans.property.*;
    import javafx.collections.*;
    import javafx.event.*;
    import javafx.scene.*;
    import javafx.scene.control.*;
    import javafx.scene.control.cell.*;
    import javafx.scene.input.*;
    import javafx.scene.layout.*;
    import javafx.stage.*;
    import java.sql.*;
    import javax.swing.*;
    public class Update extends Application
            final TableView tv = new TableView();
            final TableColumn tc1 = new TableColumn();
            final TableColumn tc2 = new TableColumn();
            final ObservableList <Tampil> data = FXCollections.observableArrayList();
            final TextField tf1 = new TextField("Nama");
            final TextField tf2 = new TextField("Npm");
            final Button b1 = new Button("Update");
            final Button b2 = new Button("Back");
            private void init ( final Stage s )
                     Group g = new Group();   
                     Scene scene = new Scene(g);
                     s.setScene(scene);
                     VBox vb = new VBox(10);
                     b1.setMaxWidth(Double.MAX_VALUE);
                     b2.setMaxWidth(Double.MAX_VALUE);
                     tc1.setText("Nama");
                     tc2.setText("Npm");
                     tc1.setCellValueFactory(new PropertyValueFactory("xnama"));
                     tc2.setCellValueFactory(new PropertyValueFactory("xnpm"));
                     tv.setItems(data);
                     tv.setEditable(true);
                     tv.setOnMouseClicked(new EventHandler<MouseEvent>()
                            @Override public void handle(MouseEvent me)
                                    if(me.getClickCount() > 0)
            int col =   0;
                                        //String nama = tv.getSelectionModel().getSelectedCells().get(0).toString();//tc1.getText().toString();
                                        //String npm = tc2.g;
                                        //System.out.println("Clicked column: " + (tv.getSelectionModel().getSelectedCells().get(0)).toString());
                                        //System.out.println("Clicked column: " + (tv.getId().toString()));
                                        //System.out.println("Clicked column: " + (tv.getSelectionModel().getSelectedCells().get(0).toString()));
                                        //System.out.println("Clicked column: " + (tv.getColumns().toString()));             
                                        System.out.println("Clicked column: " + (tv.getItems().get(0).toString()));
                                        String nama = tv.getItems().get(0).toString();
                                        //String nama = tv.getFocusModel().getFocusedCell().getColumn();
                                        String npm = tv.getItems().get(1).toString();
                                        tf1.setText(nama);
                                        tf2.setText(npm); 
                     b1.setOnAction(new EventHandler<ActionEvent>()
                            @Override public void handle(ActionEvent e)
                                    if(e.getSource()== b1)
                                            try
                                                    String nama = tf1.getText();
                                                    String npm = tf2.getText();
                                                    Class.forName ("com.mysql.jdbc.Driver");
                                                    Connection c = DriverManager.getConnection("jdbc:mysql://localhost/mahasiswa","root","");  
                                                    String sql="update data set nama ='"+nama+"', npm ='"+npm+"' where nama ='"+nama+"'or npm ='"+npm+"'";                                                                                                          
                                                    Statement s = c.createStatement();                                                     
                                                    s.executeUpdate(sql);                                                      
                                                    s.close();
                                                    c.close();
                                                    JOptionPane.showMessageDialog(null,  "Data berhasil diupdate");
                                            catch (Exception ex)
                                                    //Logger.getLogger(Menu_Utama.class.getName()).log(Level.SEVERE, null, ex);
                     tv.getColumns().addAll(tc1, tc2);    
                     vb.getChildren().addAll(tv,tf1,tf2,b1,b2);
                     g.getChildren().add(vb);
                     tampil();
            @Override public void start ( Stage  s ) throws Exception
                    init(s);
                    s.show();
            public static class Tampil
                    private StringProperty nama;
                    private StringProperty npm;
                    private Tampil(String xnama, String xnpm)
                            this.nama = new SimpleStringProperty(xnama);
                            this.npm = new SimpleStringProperty(xnpm);
                    public StringProperty xnamaProperty()
                            return nama;
                    public StringProperty xnpmProperty()
                            return npm;
            public void tampil()
                    try
                            Class.forName ("com.mysql.jdbc.Driver");
                            Connection c = DriverManager.getConnection("jdbc:mysql://localhost/mahasiswa","root","");  
                            Statement s = c.createStatement();                       
                            String sql ="select * from data";
                            ResultSet rs = s.executeQuery(sql);
                            while (rs.next())
                                    data.add(new Tampil(rs.getString(1), rs.getString(2)));
                            rs.close();
                            c.close();
                            //JOptionPane.showMessageDialog(null,  "Data berhasil dilihat");
                    catch (Exception e)
            public static void main ( String [] arguments )
                    launch ( arguments );
        }Edited by: 912711 on Feb 6, 2012 5:51 PM

  • Pl help,i need to validate the data in UI with my database-mysql

    Hello All,
    pl help.
    i'm a newbie with jdbc and mysql
    i'll tell my requirment -i need to check whether the email id in the UI matches with the email id in the db,if the email id exists,i need to find its eid(eid is t priamary key,auto_increment),i've set my email id to be unique key...
    so if the email id matches with the email id in the db,i should get the eid,other wise ,need to insert the email id in the user_table...pl help me with the code.i'm working using exadel and java...need t code 2 do this in java
    pl..pl

    The user comes to the UI and enters the email address and he hits on submit button .... (if i am right)
    it is a simple task of passing the value from jsp to action class and do those operation.
    Can u provide the code that u have wriiten... so that i can help u !!!!

  • UPDATE - Java Fx 2 Database Mysql Xampp

    Frist i want thank you very much for help me. for : https://forums.oracle.com/forums/profile.jspa?userID=899491
    And several my project almost perfect.
    Help my problem please.
    1.Login.java - Done
    2.Menu_Utama.java - Done
    3.Select.java - Done
    4.Insert.java - Done
    5.Update.java - Done
    6.Delete.java - Why after DELETE my rows can't disappear, i want not any texfield, i want if some one click table row and click button row is delete and data disappear too.
    Edited by: Tom on Feb 10, 2012 6:08 AM

    import javafx.application.*;
    import javafx.beans.property.*;
    import javafx.collections.*;
    import javafx.event.*;
    import javafx.scene.*;
    import javafx.scene.control.*;
    import javafx.scene.control.cell.*;
    import javafx.scene.input.*;
    import javafx.scene.layout.*;
    import javafx.stage.*;
    import java.sql.*;
    import javafx.beans.binding.Bindings;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javax.swing.*;
    public class Update extends Application
            final TableView tv = new TableView();
            final TableColumn tc1 = new TableColumn();
            final TableColumn tc2 = new TableColumn();
            final ObservableList <Person> data = FXCollections.observableArrayList();
            final TextField tf1 = new TextField("Nama");
            final TextField tf2 = new TextField("Npm");
            final Button b1 = new Button("Update");
            final Button b2 = new Button("Back");
            private void init ( final Stage s ) throws Exception
                     final Menu_Utama menu_utama = new Menu_Utama();
                     Group g = new Group();   
                     Scene scene = new Scene(g);
                     s.setScene(scene);
                     VBox vb = new VBox(10);
                     b1.setMaxWidth(Double.MAX_VALUE);
                     b2.setMaxWidth(Double.MAX_VALUE);
                     TableColumn<Person, String> tc1 = new TableColumn<Person, String>("Nama");
                     TableColumn<Person, String> tc2 = new TableColumn<Person, String>("Npm");
                     tc1.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));
                     tc2.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));
                     tv.getColumns().add(tc1);
                     tv.getColumns().add(tc2);
                     tv.setItems(data);
                     tv.getFocusModel().focusedItemProperty().addListener(new ChangeListener<Person>()
                            @Override public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue)
                                    if(oldValue != null)
                                            tf1.textProperty().unbindBidirectional(oldValue.firstNameProperty());
                                            tf2.textProperty().unbindBidirectional(oldValue.lastNameProperty());
                                    if(newValue != null)
                                            tf1.textProperty().bindBidirectional(newValue.firstNameProperty());
                                            tf2.textProperty().bindBidirectional(newValue.lastNameProperty());
                     b1.setOnAction(new EventHandler<ActionEvent>()
                            @Override public void handle(ActionEvent e)
                                    if(e.getSource()== b1)
                                            try
                                                    String nama = tf1.getText();
                                                    String npm = tf2.getText();
                                                    Class.forName ("com.mysql.jdbc.Driver");
                                                    Connection c = DriverManager.getConnection("jdbc:mysql://localhost/mahasiswa","root","");  
                                                    String sql="update data set nama ='"+nama+"', npm ='"+npm+"' where nama ='"+nama+"'or npm ='"+npm+"'";                                                                                                          
                                                    Statement s = c.createStatement();                                                     
                                                    s.executeUpdate(sql);                                                      
                                                    s.close();
                                                    c.close();
                                                    JOptionPane.showMessageDialog(null,  "Data berhasil diupdate");
                                            catch (Exception ex)
                                                    //Logger.getLogger(Menu_Utama.class.getName()).log(Level.SEVERE, null, ex);
                     b2.setOnAction(new EventHandler<ActionEvent>()
                            @Override public void handle(ActionEvent e)
                                    if(e.getSource()== b2)
                                            try
                                                    menu_utama.start(s);
                                            catch (Exception ex)
                                                    //Logger.getLogger(Menu_Utama.class.getName()).log(Level.SEVERE, null, ex);
                     vb.getChildren().addAll(tv,tf1,tf2,b1,b2);
                     g.getChildren().add(vb);
                     tampil();
            @Override public void start ( Stage  s ) throws Exception
                    init(s);
                    s.show();
             public class Person
                    private StringProperty firstName;
                    private StringProperty lastName;
                    public Person(String firstName, String lastName)
                            setFirstName(firstName);
                            setLastName(lastName);
                    public final void setFirstName(String value)
                            firstNameProperty().set(value);
                    public String getFirstName()
                            return firstNameProperty().get();
                    public StringProperty firstNameProperty()
                             if(firstName == null)
                                    firstName = new SimpleStringProperty(this, "firstName");
                             return firstName;
                    //=======================================================
                    public final void setLastName(String value)
                             lastNameProperty().set(value);
                    public String getLastName()
                            return lastNameProperty().get();
                    public StringProperty lastNameProperty()
                            if(lastName == null)
                                    lastName = new SimpleStringProperty(this, "lastName");
                            return lastName;
            public void tampil()
                    try
                            Class.forName ("com.mysql.jdbc.Driver");
                            Connection c = DriverManager.getConnection("jdbc:mysql://localhost/mahasiswa","root","");  
                            Statement s = c.createStatement();                       
                            String sql ="select * from data";
                            ResultSet rs = s.executeQuery(sql);
                            while (rs.next())
                                    data.add(new Person(rs.getString(1), rs.getString(2)));
                            rs.close();
                            c.close();
                            //JOptionPane.showMessageDialog(null,  "Data berhasil dilihat");
                    catch (Exception e)
            public static void main ( String [] arguments )
                    launch ( arguments );
        }   

  • To transfer all images from a folder to database(mysql)

    Hello folks ,
    i would be really helpful as i am working on a project where in i need to give the folder path where 100's of images are stored and i need to retrieve all the image files at once.
    when i use html:file tag of struts i am able to retrieve only one file is there any tag where in i can give the folder and retrieve all the contents

    No dude. Thats not possible. As send by our buddy you can zip a folder and the upload.
    Regards
    kk

  • HOW TO DO VALUE ADOBE EDGE ANIMATE CONNECTED WITH JQUERY FOR DATABASE MYSQL??

    Please give me a suggestion...
    thank's attention...

    Check this link out:
    Receiving INPUT TEXT, making Forms from scratch.
    The idea is that a symbol is created and the input controls are created or attached to the symbol. For example, we create a rectangle on the stage, convert it to a symbol then name it "username". We can then do the following:
    sym.$("username").append('<input/>').attr({ type: 'text', name:'text', value:'text'});
    Add the above code in the stage compositionReady event. The above will add a text input control.

  • How can I upload an image using JSP in database(MySQL)

    I have to develop an application in which users can register themselve by filling up thier information(name, address) etc along with their photo.
    Storing nam etc. is simple but i am unable to upload photo using JSP.

    Here are lot of examples: http://www.google.com/search?q=jsp+file+upload
    Or if you actually have implemented something which doesn't work as expected, then please ask specific questions.

  • Php/mysql: can't write to mysql database [SOLVED]

    I'm writing a login script using php and mysql. I got it to work on my server about a week ago, and then I set up apache, php and mysql on my netbook so that I could take my code with me and test it. Now it doesn't work. My registration script doesn't write to the mysql database but has no errors. Here is register.php:
    <?php
    define("DB_SERVER", "localhost");
    define("DB_USER", "root");
    define("DB_PASS", "swordfish");
    define("DB_NAME", "users");
    define("TBL_USERS", "users");
    $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
    mysql_select_db(DB_NAME, $connection) or die(mysql_error());
    function addUser($username, $password)
    global $connection;
    $password = md5($password);
    echo("adding $username,$password<br />");
    $q = "INSERT INTO " . TBL_USERS . " VALUES ('$username', '$password')";
    echo("query: $q<br />");
    $result = mysql_query($q, $connection);
    echo("$result<br />");
    if (isset($_POST["reg"]))
    addUser($_POST["username"], $_POST["password"]);
    echo("<a href='index.php'>click here to login</a>");
    ?>
    <html>
    <head>
    <title>Register</title>
    </head>
    <body>
    <form method="Post" name="login">
    <input type="text", name="username" /> Username<br />
    <input type="text", name="password" /> Password<br />
    <input type="submit" name="reg", value="Register" />
    </form>
    </body>
    </html>
    and here is the output (without the form):
    adding lexion,6f1ed002ab5595859014ebf0951522d9
    query: INSERT INTO users VALUES ('lexion', '6f1ed002ab5595859014ebf0951522d9')
    Also, I tried manually adding the content to the database:
    $ mysql -p -u root
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 9
    Server version 5.1.42 Source distribution
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql> users
    -> INSERT INTO users VALUES('lexion', 'foo')
    -> ^D
    -> Bye
    I would assume that I got something wrong with the last bit, but the php script seems like it should work. Does anybody know why it doesn't?
    Last edited by Lexion (2010-01-10 19:04:15)

    What is wrong with your PHP? Why do you think it is failing? An INSERT query doesn't return anything. Also, it's a good idea to specify which fields you are inserting into, unless you want to have to provide something for every field (tedious for tables with many fields with default values). eg:
    $q = "INSERT INTO `" . TBL_USERS . "`(`username`, `password`) VALUES ('$username', '$password')";
    As for your experiment with the mysql prompt; queries have to end with a semicolon. PHP is nice and hides that little detail from you.
    edit: Also, you're echoing text out before the HTML starts. That won't produce valid HTML. I also noticed a few other things which I corrected; look at my comments:
    <?php
    define("DB_SERVER", "localhost");
    define("DB_USER", "root");
    define("DB_PASS", "swordfish");
    define("DB_NAME", "users");
    define("TBL_USERS", "users");
    $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
    mysql_select_db(DB_NAME, $connection) or die(mysql_error());
    function addUser($username, $password)
    global $connection;
    $password = md5($password);
    // echo("adding $username,$password<br />"); - Don't echo stuff before HTML starts.
    // Also, clean up user-supplied data before plugging it into a query unless you want to be vulnerable to SQL injection.
    $cleanusername = mysql_real_escape_string($username, $connection);
    $cleanpassword = mysql_real_escape_string($password, $connection); // Obviously you'd generally use some hashing algorithm like md5 or sha1 for passwords
    $q = "INSERT INTO `" . TBL_USERS . "`(`username`, `password`) VALUES ('{$cleanusername}', '{$cleanpassword}')"; // The backticks tell MySQL not to interpret any text within as a keyword (good for field names, eg a field called `date`. The curly brackets tell PHP that the stuff within refers to a variable; it's nice as PHP knows exactly what the variable name is with no possible ambiguity.
    // echo("query: $q<br />");
    $result = mysql_query($q, $connection);
    // echo("$result<br />"); - This won't do anything; in addition to INSERT queries not returning anything, the $result variable doesn't contain the results of the query, it's a pointer to them for use with mysql_result().
    ?>
    <html>
    <head>
    <title>Register</title>
    </head>
    <body>
    <?php
    if (isset($_POST["reg"]))
    addUser($_POST["username"], $_POST["password"]);
    echo("<a href='index.php'>click here to login</a>");
    ?>
    <form method="Post" name="login">
    <input type="text" name="username" /> Username<br />
    <input type="text" name="password" /> Password<br />
    <input type="submit" name="reg" value="Register" />
    </form>
    </body>
    </html>
    <?php
    mysql_close($connection); // Not strictly needed, as PHP will tidy up for you if you forget.
    ?>
    Last edited by Barrucadu (2010-01-10 17:34:20)

Maybe you are looking for

  • ITunes won't recognize my new Nano (already have ipod 5.0)

    Hello- I installed the software for my new nano. When I attach the nano, iTunes says that something is wrong with the software and that I need to re-install iTunes. My 5.0 ipod still connects fine. My main question is: what is the trick to having iTu

  • Warning on Devices and printers in Windows 7

    I have a G60-637CL Notebook computer. I was not able to correct a warning on the notebook itself before the warranty with HP expired. In the Devices and Printers display the notebook symbol itself has a yellow triangle with an exclamation mark in it.

  • Trying to Update Logic 7.1 to 7.2.3

    Hey! Hello everyone. I missed a couple of upgrades and now I am trying to catch up. I downloaded the installer for 7.2.1 and 7.2.3, but both say I need to have updated to 7.2 first. But I can't find the installer for 7.2 anywhere!!! Can anyone help m

  • How can I get a list of my registered HP Products

    have registered all of my HP products, is there somewhere where I can view a list of them? Quite awhile back I used to be able to go to "my products" but cannot find that tab on the HP site.

  • SAP XI vs Oracle BPEL/ESB/SOA

    Hi, Wondering!  What would the percentage of implementations SAP XI vs Oracle BPEL/ESB/SOA for next couple of years.  I just wanna explore and know more about them..  How's XI doing in terms of new customers/implementations and what are all market tr