Is it possible to insert data into a MySQL database with Java?

Hello everyone!
I would like to know, if it's possible to insert data into a MySQL database, with a JFrame inside a servlet?
When the JFrame is first created it calls this method:
     * Connects the servlet with the MySQL database.
    private void connect(){
        try{
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/data", "root", "omfg123");
        }catch(ClassNotFoundException cnfe){
            cnfe.printStackTrace();
        }catch(SQLException sqle){
            sqle.printStackTrace();
    }Then, when you click the "Add" button, it executes this code:
            add.addActionListener(new ActionListener(){
                @Override
                public void actionPerformed(ActionEvent ae){
                    String employee = employeeName.getText();
                    String[] args = employee.split(" ");
                    firstName = args[0];
                    lastName = args[1];
                    execute();
            });And this is my "execute()" method:
     * Connects the servlet with the MySQL database.
     * - And executes the SQL queries.
    private void execute(){
        try{
            PreparedStatement statement = connection.prepareStatement("insert" +
                    " into employees values(" + firstName + ", " + lastName
                    + ")");
            ResultSet result = statement.executeQuery();
            String fullName = firstName + " " + lastName;
            printer.write("Employee " + fullName + " added.</br>");
        }catch(SQLException sqle){
            sqle.printStackTrace();
    }But when I click the "Add" button, nothing happens.

This is what I use to insert into mysql. It works on windows.
try {
            Class.forName("com.mysql.jdbc.Driver");
            String connectionUrl = "jdbc:mysql://" + loadip + "/custsig?" +
                    "user=root&password=";
            Connection con = DriverManager.getConnection(connectionUrl);
            newproc = jTextField1.getText();
            newsoft = jTextField2.getText();
            newdeb = jTextField3.getText();
            newcust = jTextField4.getText();
            if (newcust.equals("")) {
                errorsig12 = 1;
                jLabel1.setForeground(new java.awt.Color(255, 0, 0));
            } else if (newsoft.equals("")) {
                errorsig12 = 1;
                jLabel2.setForeground(new java.awt.Color(0, 0, 0));
            } else if (newproc.equals("")) {
                errorsig12 = 1;
                jLabel3.setForeground(new java.awt.Color(0, 0, 0));
            } else if (newdeb.equals("")) {
                errorsig12 = 1;
                jLabel4.setForeground(new java.awt.Color(0, 0, 0));
            if (errorsig12 == 0) {
                PreparedStatement ps = con.prepareStatement("insert into customer set cust_name = ?,  software = ?, processor = ?, debit = ?");
                ps.setString(4, newdeb);
                ps.setString(3, newproc);
                ps.setString(2, newsoft);
                ps.setString(1, newcust);
                int rs = ps.executeUpdate();
        } catch (SQLException eg) {
            System.out.println("SQL Exception: " + eg.toString());
        } catch (ClassNotFoundException cE) {
            System.out.println("Class Not Found Exception: " + cE.toString());
        }

Similar Messages

  • Inserting data into a MySQL database

    Hi. I am currently working on a group project and know very little about java to be honest
    I'm trying to insert records into a local MySQL database, but I'm having trouble.
    When the application is started, a connection is made to the database, which, as far as I can tell is successful. The user adds the data through a method in a console class which then passes the parameters to 'insertCustomer' method in class DatabaseIO.
    Connection code from DatabaseIO class
    public static void openDatabase(){
    //          start by making the connection
              try{
                   //System.out.println("setting up class");
                   Class.forName("com.mysql.jdbc.Driver");
              catch(Exception e){
                   System.out.println("Driver set up error" + e);
              try{
                   url="jdbc:mysql://localhost:3306/db0611426";
                   con=DriverManager.getConnection(url,"root","");
                   System.out.println("setting up database");
                   Opened = true;
              catch (Exception e){
                   System.out.println("database connection error"+ e);
         }Add customer form
    public void addCustomer() {
                        int customerID, depositPercentage;
                        String firstName, lastName, address, phoneNumber, add;
                        boolean purchaser;
                        double budget;
                        System.out.println("\n*** Enter Customer details: ***");
                        customerID = TextInputPrompt.getInteger("Customer ID Number: ");
                        firstName = TextInputPrompt.getString("First Name: ");
                        lastName = TextInputPrompt.getString("Last Name: ");
                        address = TextInputPrompt.getString("Address: ");
                        depositPercentage = TextInputPrompt.getInteger("Deposit Percentage");
                        budget = TextInputPrompt.getDouble("Budget");
                        purchaser = TextInputPrompt.getBoolean("Purchaser?");
                        phoneNumber = TextInputPrompt.getString("Phone Number: ");
                        add = TextInputPrompt.getString("Add Customer Y/N?: ");
                        if (!add.equalsIgnoreCase("y"))
                             return;
                        customers.addCustomers(new Customer(purchaser, customerID, firstName, lastName, address, phoneNumber, depositPercentage, budget));
                        DatabaseIO.insertCustomer(purchaser, customerID, firstName, lastName, address, phoneNumber, depositPercentage, budget);
              }Constructor in customer class
    public Customer(boolean purchaser,int customerID,String firstName,String lastName,String address,String phoneNumber,int depositPercentage,double budget) {
              super();
              this.purchaser = purchaser;
              this.customerID = customerID;
              this.firstName = firstName;
              this.lastName = lastName;
              this.address = address;
              this.phoneNumber = phoneNumber;
              this.depositPercentage = depositPercentage;
              this.budget = budget;
         }Code to insert customer into table (DatabaseIO class)
    //add a new customer to the customers table
         public static void insertCustomer(boolean purchaser,int customerID,String firstName,String lastName,String address,String phoneNumber,int depositPercentage,double budget){
             String query = "INSERT customer (purchaser,customerID,firstName,lastName,address,phoneNumber,depositPercentage,budget) VALUES ('"+purchaser+"','"+customerID+"','"+firstName+"','"+lastName+"','"+address+"','"+phoneNumber+"','"+depositPercentage+"','"+budget+"')";
             System.out.println("inserting "+ query);
             try{
                  Statement stmt = con.createStatement();
                  int rs = stmt.executeUpdate(query);
             catch (Exception e){
                  System.out.println("insert failed");
        }After entering the data, the 'insert failed' is displayed in the console. Any suggestions on how to solve the problem or any ways of finding out more about the exception would be very much appreciated, thanks in advance!

    Here's how to find out more about the exception:
    catch (Exception e){
      System.out.println("insert failed");
      e.printStackTrace();
    }

  • How to insert data into the mysql table by giving as a text file

    Hi,
    Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
    Thanks:)

    At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).

  • How to insert date into ms access database using sql query in servlet

    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
      plz help me
    thanx                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    bhavishya wrote:
    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
    plz help me
    thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack.

  • How to insert data into two tables linke with foreign key..

    I have two tables
    1)EMP(emp_ID,username,emp_type_code)
    emp_ID is primary key, emp_type_code is a foreign key references emptype table.
    2)emptype(emp_type_code,emp_type_descripton)
    emp_type_code is primary key
    Could anyone help me ..how to insert data into EMP table. How to insert data into two tables linke with foreign key..

    CREATE TABLE "CATDB"."DWDIMUSER"
    "USER_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_ID" NUMBER(10,0),
    "FULLNAME" VARCHAR2(20 BYTE),
    "FNAME" VARCHAR2(20 BYTE),
    "LNAME" VARCHAR2(20 BYTE),
    "USER_SUBTYPE" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMUSER_PK" PRIMARY KEY ("USER_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE,
    CONSTRAINT "DIMUSER_DIMSPECIALTY_FK" FOREIGN KEY ("SPECIALTY_ID") REFERENCES "CATDB"."DWDIMSPECIALTY" ("SPECIALTY_ID") DISABLE
    CREATE TABLE "CATDB"."DIMSPECIALTY"
    "SPECIALTY_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_NAME" VARCHAR2(100 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("SPECIALTY_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    INSERT INTO DIMUSER (FullName, FNAME, LNAME, USER_TYPE, USER_SUBTYPE)
    SELECT DISTINCT
    Engineer AS FullName,
    regexp_substr(Engineer , '[^,| ]+', 1, 1) as FName,
    regexp_substr(Engineer , '[^,| ]+', 1, 2) as LName ,
    'Engineer'
    FROM EMPLOYEELOOKUP;
    INSERT INTO DIMSPECIALTY (SPECIALTY_NAME)
    SELECT DISTINCT SPECIALITY
    FROM EMPLOYEELOOKUP;
    COMMIT;
    CREATE TABLE employeelookup ...IS A TABLE THAT HAS ALL THE DATA NEDED TO BE FILLED IN BOTHE TABLES...
    CREATE TABLE "CATDB"."EMPLOYEELOOKUP"
    "EMPLOYEELOOKUP_ID" NUMBER(10,0) NOT NULL ENABLE,
    "ENGINEER" VARCHAR2(25 BYTE),
    "SPECIALTY" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("EMPLOYEELOOKUP_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    DATA IN EMPLOYEELOOKUP
    Engineer, Specialty,
    John, Dow, Electronis,
    Dow, Jons, Technician
    Stan Smithers Sales
    Mark, Richards Marketing
    Jenny, Lane Marketing
    John, Lee Sales
    I NEED TO LOAD THE FOREIGN KEY IN DIMUSER FROM THE DIMSPECIALTY TABLE?
    BY USING THE LOOKUP TABLE TO MARCH THE NAMES UNDER THE Engineer COLUMN, SPECIALTY COLUMNE DISTICTIVLY BY JOINING THE DIMSPECILTY TO RISTIVE THE PRIMARY KEY AND FILL IT IN THE DIMUSER TABLE AS A FOREIGNE KEY.

  • I can insert data into an access database, but I need to querry the database for specific information. How do I do it?

    I can insert data into an access database, now I need to do some simple querries such as selecting all records that are greater than a certain value or = a certain value. How can I return only the selected records?

    If you don't want to spend any money, then instead of ActiveX, I would recomend LabSQL from Jeffrey Travis. I use it instead of the Connectivity toolkit and have had no problems. Besides being free, you have the advantage of being able to use it with any database. ActiveX ties you to Access and you upgrade your version of Access and find the properties and methods are different, you've got a lot of reprogramming to do.

  • Is it possible to insert data into two Excel worksheets using Report Generation Toolkit?

    I'm using the toolkit to insert data into two separate worksheets in Excel using named cells. The problem is that it tends to favor one sheet or the other. In other words, one sheet will have data and the other no data and vice versa. (Sometimes I get data in both sheets.) Is there something I can do to clear this up or is what I'm trying to do unreasonable? I would like to use two worksheets so one sheet receives text and data. The other sheet is used to format the data into a printable report. (i.e. using Excel's CONCATENATE function) The second (report) sheet is also used to receive plots (JPEG files) from LabVIEW. I'd send the plot images to the first sheet, but I can
    not see a way to automatically transfer images from sheet to sheet. I'm using LV 7.1, Win2000 and Toolkit v.1.0.1

    Hi,
    You can use the "Excel Get Worksheet.vi" under All Functions >> Report Generation >> Excel Specific >> Excel General to specify a particular worksheet as the current worksheet. Then, you can specify which worksheet you want to write to in your VI.
    Let me know if you have any further questions and good luck!
    Kileen C.
    NI

  • How can I Insert data into my msaccess Database table

    Hello all,
    I am new to Java programming and I have problem that how can i insert name into my database table.
    The code which i have written is following:
    String filename = "d:/test.mdb";
    String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    database+= filename.trim() + ";DriverID=22;READONLY=true}";
    Connection con = DriverManager.getConnection(database,"","");
    String s = String.valueOf(text.getText());
    int k =10;
    Statement st = con.createStatement();
    st.execute("create table Test123(name text)");
    st.execute("INSERT INTO Test123 values" +s);
    on the INSERT program throws exception???
    can any one help me how to insert data into tabel.
    Thanks

    he INSERT program throws exception???
    can any one help me how to insert data into tabel.I have never used the jdbc driver to access, but what do you think that the flag READONLY=true means? An insert is not a read.
    Kaj

  • How do I run a database procedure that inserts data into a table from withi

    How do I run a database procedure that inserts data into a table from within a Crystal report?
    I'm using CR 2008 with an Oracle 10i database containing a number of database tables, procedures and packages that provide the data for the reports I'm developing for my department.  However, I'd like to know when a particular report is run and by whom.  To do this I have created a database table called Report_Log and an associated procedure called prc_Insert_Entry that inserts a new line in the table each time it's called.  The procedure has 2 imput parameters (Report_Name & Username), the report name is just text and I'd like the username to be the account name of the person logged onto the PC.  How can I call this procedure from within a report when it's run and provide it with the 2 parameters?  I know the procedure works, I just can't figure out how to call it from with a report.
    I'd be grateful for any help.
    Colin

    Hi Colin, 
    Just so I'm clear about what you want: 
    You have a Stored procedure in your report.  When the report runs, you want that same procedure to write to a table called Report_Log. 
    If this is what you want the simple answer is cannot be done.  Crystal's fundamental prupose is to read only, not write.  That being said, there are ways around this. 
    One way is to have a trigger in your database that updates the Report_Log table when the Stored Procedure is executed.  This would be the most efficient.
    The other way would be to have an application run the report and manage the entry. 
    Good luck,
    Brian

  • How to get data into the mySQL database?

    First some background.
    I have a website that has outgrown its designed dimensions and is a huge burden to maintain. See PPBM5 Benchmark
    There is a lot of maintenance work involved, so I'm investigating a PHP/MySQL approach to easen the burden and to add functionality to the site. With the current Excel based structure and over 420 entries, it is cumbersome for me to maintain, but also for users to find what they need.
    A MySQL based dynamic structure is a lot easier and offers vastly more selection capabilities, like selecting only records that meet specific criteria.
    Data submission is done with a form, that contains most of the relevant data, but the drawack is that people submitting their data are often not technically inclined, give wrong answers due to a lack of understanding or making typo's. The test results are attached in one or two separate .txt files, but often they have not read the instructions correctly or did something wrong, so these attached .txt files can not be trusted automatically, they have to be checked before inclusion.
    These were my initial thoughts:
    1. Data collection:
    To avoid spending all our energy and time  on correcting typo's, getting missing data, correcting errors, I am  investigating the use of CPU-Z in Ghost mode to create a .txt or .html  file that contains all relevant hardware info we need and even more. It gives all the info we currently have, but adds  data like number of memory sticks, DDR timings, stock clock speed and  BCLK setting, video card info and VRAM size, etc.
    To see what I mean, run CPU-Z, go to the About tab and press the Save Report button and look at the results.
    This can all be done without user intervention in an automatic way, but  maybe I need to add an Auto-It file to the test to make it all run as  desired.
    If this works and I'm able to extract the relevant data from the created  file and can insert it into the database, we may be in business for the  next version of PPBM5.5 or PPBM6. It does require a modification to the instructions, making them a lot  easier, because there is less data to fill out.
    2. Data submission:
    The submission form can be simplified if  the CPU-Z data can be used. We have to create an automatic way to attach  the created .html file from CPU-Z to the submission form and we have to  streamline the Output.txt and Output-MPE.txt files to be more easily included in the 'form.lib.php' file. It  currently is manual labor and very time consuming.
    3. Adding to Database:
    I have to find a way to create database  records from the Gmail forms I receive. All incoming mail messages need  to be checked on relevancy and if relevant, need to be added  automatically to the database and then offered for approval before final inclusion in the database. Data included in the database  will then include submission date and time, Email address,  IP address  used, plus links to the files submitted and available on the website.
    4. Publication of the database:
    After approval of new records from step  3, all updates will be automatically applied to the database and  accessible for users. I do not yet intend to introduce a user account ,  requesting login before all functionality is accessible. Too much trouble and administration.
    Queries should be possible on things like CPU (check box), so include  17-920, i7-930, i7-950 but exclude i7-980X and i7-990X, Size of memory  (check box), Overclocked (boolean, yes, no), SSD as OS disk, and similar  options.
    The biggest problem is to keep the color grading and statistical  indicators (Top, D9, Q3, Med, Q1 and D1) intact on dynamically generated  queries. Say you make a query which results in 20 observations, this  should show the related colors and legends. Next query results in 48 observations and of course the color grading and legends  do need to reflect that. Question in my mind, does the RPI remain  constant, independent of the query or does that need to be recalculated  on the basis of the query?
    Next thing is to allow a user to select a specific observation and by  simply clicking on it be shown, in a separate window (detail page) or  accordion, all the CPU-Z related information about the hardware.
    The graphs, Top-20 and MPE Gains, need to be dynamically adjusted, based on the query used.
    5. Ideally, external links:
    In an ideal situation, one could link the  CPU-Z data to external price databases, looking up current prices for  CPU, memory, video card, disks, raid controller, etc. to get instant  BFTB charts, based on the query made. But that is the next step.
    Situation now:
    I have a MySQL database that is easily updated with the new submissions. Simply create a .CSV flie from the submitted forms and import that into the database. The bulk of the initial work is done.Lots remain to be done as you can see above, but that is for a later time.
    Question:
    I have this table, that needs to be filled with data in the submitted and attached files. Mr. X submitted his data and can be uniquely identified by his "Ref_ID". He attached one or two files in .TXT format with the relevant test data. These files are stored on the server with a concatenated name:
    "Ref_ID","-","filename"
    Say his Ref-ID is: 20110204-6cf5 and his submitted file is called: Output(99).txt then the file can be found on the server as
    20110204-6cf5-Output(99).txt
    I need to be able to open that comma delimited file, the contents may look like this: "439","1036","819","531" and insert these contents into the relevant record and fields.
    Graphically,
    is what I want to achieve.
    This being my first exposure to PHP/MySQL, you can imagine I'm not clear on how to go from here.
    Added complication is that I actually have 5 numbers to insert per record and two calculated fields, Total Score and RPI should be calculated fields. Haven't yet figured out how to handle calculated fields, maybe only in the PHP/HTML code and not in the database.
    I hope someone can help me.

    You do have a very complex looking site and may need several tables in mysql to handle all that data. If you knew to phpmysql I would suggest taking a look at this tutorial it will help get you started in understanding how to $_GET info from a database and also how to $_POST data to a database. I am no expert just learning myself and I found this very helpful. This is the link http://www.adobe.com/devnet/dreamweaver/articles/first_dynamic_site_pt1.html
    There are also many tutorials on Youtube to help build a CMS Content Management Site I would suggest the following: -
    http://www.youtube.com/user/phpacademy
    http://www.youtube.com/user/betterphp
    http://www.youtube.com/user/flashbuilding
    And many more on my channel here
    http://www.youtube.com/user/Whisperingonthewind
    CMS's are easier to maintain, add edit and delete content.
    I have also recently bought a Book by David Powers Training from the Source very helpful.
    Anyway hope you get it sorted.

  • How To Insert Data into a Access Database from a PDF File

    Hi All,
    Could anyone help me to insert PDF form data to an MS Access database.I am new to this and I would appreciate if anyone can help me at the earliest.
    Thanks,
    Deepti

    You can submit your PDF to a server-side script (ASP/PHP), and store the new record in a MS Access database.
    For more information on how to store your PDF submission in a database, please visit:
    http://www.fdftoolkit.net

  • Inserting data into a file in Webdynpro java

    hi,
    My requirement is, i am using html code in my webdynpro application. i want to send the html code to a file(.txt file) .can any body help me how to send the data to file in webdynpro java.
    thans,
    kishore

    Hi,
    For export file in format XML, TXT, ...
    continue steps
    1) create node with name  FileResource and type binary
    2) create view and add control filedownload and properties control set data binding node FileResource
    3) create following code
      //@@begin javadoc:wdDoInit()
        /** Hook method called to initialize controller. */
      //@@end
      public void wdDoInit()
        //@@begin wdDoInit()
            IWDAttributeInfo attInfo = wdContext.getNodeInfo().getAttribute(IPrivateExportListView.IContextElement.FILE_RESOURCE);
            IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();  
            binaryType.setFileName(ExportListView.FILE_NAME);
            binaryType.setMimeType(WDWebResourceType.TXT);
            try {
                String resourcePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), ExportListView.FILE_NAME);
                wdContext.currentContextElement().setFileResource(this.getByteArrayFromResourcePath(resourcePath));
            } catch (WDAliasResolvingException e) {
                wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), true);
            } catch (Exception e) {
                throw new WDRuntimeException(e);
        //@@end
    and add following code
      //@@begin others
        private byte[] getByteArrayFromResourcePath(String resourcePath) throws FileNotFoundException, IOException {
            FileInputStream in = new FileInputStream(new File(resourcePath));
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            int length;
            String Prueba = "hola esto es una prueba" + new Date().getSeconds();
            //byte[] part = new byte[10 * 1024];
            byte[] part = Prueba.getBytes();
            while ((length = in.read(part)) != -1) {
                out.write(part, 0, length);
            out.write(Prueba.getBytes());
            in.close();
            return out.toByteArray();
        // store image file name in constant FILE_NAME
        private static final String FILE_NAME = "doc.txt";
      //@@end
    4)Create file ext(txt,xml,...) in following dir of the project
    ...\_comp\src\mimes\Components\com.prueba.ReporteComp
    regards from colombia-medellín

  • Entering data into a mySQL database for use with my JDBC program

    does any know what i type on telnet to get mySQL to work on windows 2000?
    i read check your isp for what to type in for this line, but i use IIS
    www24:mywww/devshed# mysql -u devshed -p
    and what do i put for
    login: devshed
    Password: ********
    it says check with isp on that one too
    i am trying to insert records, and make columns, is there an easier way to do this?
    thanks,
    Pearl
    Beginning MySQL Tutorial
    By W.J. Gilmore
    April 03, 1999
    Part 1: At First Glance
    MySQL is most commonly entered through telnet. (A nice Telnet program, Easyterm, can be found at http://www.arachnoid.com) Once the telnet connection to the web server has been accomplished, a second command provides access to the MySQL server. The procedure to make these connection is as follows:
    1. Connect to telnet. This involves the insertion of the given ISP username and password.
    --------------------------------------------------------------------------------login: devshed
    Password: ********
    Last login: Wed Aug 12 09:49:14 from 195.103.124.222
    Copyright 1992, 1993, 1994, 1995, 1996 Berkeley Software Design, Inc.
    Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
    The Regents of the University of California. All rights reserved.
    BSDI BSD/OS 2.1 Kernel #12: Mon Feb 23 13:46:27 EST 1998
    You have new mail.
    www24:mywww/devshed#
    2. Connect to MySQL. This involves the insertion of the username and password given specifically for MySQL use. This information has probably been provided to you at your request to the ISP provider.
    --------------------------------------------------------------------------------www24:mywww/devshed# mysql -u devshed -p--------------------------------------------------------------------------------
    Syntax: mysql -h hostname -u username -p[password]
    Or
    mysql -h hostname -u username --password=password
    The user will then be prompted for a password, as prompted by -p.
    --------------------------------------------------------------------------------Enter password: *******--------------------------------------------------------------------------------
    Assuming MySQL has been correctly installed and configured, the user will see output similiar to the following:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 49 to server version: 3.21.23-beta-log
    Type 'help' for help.
    mysql>
    (Note: If an error message pertaining to "Access denied" is the result of connection attempts, you should consult the MySQL documentation included with the software, the MySQL mailing list found at http://www.mysql.com, as well as your ISP provider. These resources will aid greatly in resolving these problems.)
    Once connected to the database, we are free to execute the various commands of the MySQL language. However before we are able to modify the database, we must first connect to it, via the command:
    --------------------------------------------------------------------------------mysql> use devshed;
    Result:
    --------------------------------------------------------------------------------Database changed
    Mysql>
    You now are connected to the database. Note that the command was followed by a semi-colon (;). Almost all commands in MySQL are followed by a semi-colon.
    At the disposition are a number of administrative commands. These commands can be viewed simply by typing help, \h or ? at the command line:
    --------------------------------------------------------------------------------mysql> help
    help (\h) Display this text
    ? (\h) Synonym for `help'
    clear (\c) Clear command
    connect (\r) Reconnect to the server. Optional arguments are db and host
    edit (\e) Edit command with $EDITOR
    exit (\) Exit mysql. Same as quit
    go (\g) Send command to mysql server
    print (\p) print current command
    quit (\q) Quit mysql
    rehash (\#) Rebuild completion hash
    status (\s) Get status information from the server
    use (\u) Use another database. Takes database name as argument
    Connection id: 49 (Can be used with mysqladmin kill)
    mysql>

    Let's make this simple:
    a) Your book seems to assume you're doing development remotely.
    b) You are not doing development remotely.
    c) Therefore, you shouldn't follow every step listed in your book (i.e. ignore the stuff about Telnet).
    Assuming you installed mySQL in the standard location, you can use this batch file to start mySQL on your machine:
    @echo on
    cd c:\mysql\bin
    mysqld
    @echo off
    cls
    Use this batch file to shut down mySQL:
    @echo on
    cd c:\mysql\bin
    mysqladmin shutdown
    @echo off
    cls
    You can play around without a login or password in development. For a production environment, you're going to need to set up users and grant permissions.
    Spend some time reading the mySQL documentation.

  • Use Spry to insert data into a database?

    I'm new to Spry, so I have a question:
    Can I use Spry to insert data into a MySQL database without
    reloading the site?
    Reading data from XML file works fine, but I don't know if
    writing is possible..

    I don't get it... I tried this:
    <script type="text/javascript" src="spry/xpath.js"
    /></script>
    <script type="text/javascript" src="spry/SpryData.js"
    /></script>
    <script type="text/javascript">
    /* <![CDATA[ */
    function subscribe() {
    var subscribe;
    var info =
    document.getElementById("subscription_info").value;
    if (document.getElementsByName("subscription")[0].checked ==
    true) {
    subscribe = "ja";
    else {
    subscribe = "nein";
    var dsSubscribe = new
    Spry.Data.XMLDataSet("include/inc_subscribe.php?subscribe="+subscribe+"&info="+info+"&sit e=<?=$_GET['site'];?>",
    "subscription/ok");
    /* ]]> */
    </script>
    <div id="infos">
    <input type="radio" name="subscription" value="ja" />
    dabei
    <input type="radio" name="subscription" value="nein"
    /> nicht dabei
    <input type='text' class='text'
    id='subscription_info_text' />
    <input type='submit' id="subscription_submit"
    value='Eintragen' onClick="subscribe()" />
    </div>
    But the data isn't inserted into the mysql database. When I
    start the php script directly, it works, so I think it's not a php
    problem.

  • Insert data into array

    I want to know if its possible to insert data into an array, but I wish to do it as I would in excel, by using the option of insert row.
    Is it possible to insert a value into an array in a specific row, so that all the other values after the one that was inserted are moved one row down?
    Please let me know how to do this, and if you could please provide some sample code, that would be great.
    Thanks!

    I tried using the array subset, but I still can't get the result that I want.
    What I want is to be able to add elements to the array, and that element should be added to a specific category (defined by one of the text rings).
    Example: in the category, I have the first one and in the elements (second text ring) I have the second one. The element that I will add will be in the 3rd position of the category that I selected. So if I have a category of DVDs, and in the items I have 2 brands (TDK, Maxell), and I will add Sony as the 3rd item in the second text ring that is being populated depending on the selection in the first text ring.
    How can I add items to the second text ring, so that they only appear in the category that I selected in the first text ring?
    Thanks in advance!

Maybe you are looking for

  • Add a new field to vtts

    How to add a new field to VTTS? With an append? Thank you

  • STS: Portal HTTPS to BSP HTTP transfer issue

    Hi Experts, We have the following issue. We use portal with SSL, and we put SSL on out BW backend system. We also use STS, and we created a BSP iView in the portal to use STS inside portal. The problem occurs when a link to the iView is clicked. What

  • HP Pavillion Media Center m8020n audio add in?

    HI, I have a Media Center M8020n... Product #: RX883AA-ABA07010#32#203211022006 running vista. The sound has recently died, and I am trying to figure out what to do with it. I realize it's pretty out of date at this point, but everything still works,

  • Creating spatial index on spatial table

    Hi there. Just a quick query on creating spatial indexes on spatial tables. I have a table called System_Sessions which has the following four fields and types: USER_ID NUMBER(10) SESSION_ID NUMBER(10) SESSION_BOUNDARY MDSYS.SDO_GEOMETRY (polygon) ST

  • Transfer Adobe files

    Hello I have created a website using Adobe Dreamweaver.  I downloaded a trial version of Adobe CC.  Is there a way I can transfer my files from DW over? Thanks Nick