Share on Google+Share on Google+

sakthi
db error
2 Answer(s)      8 years ago
Posted in : Java Beginners

Ads

View Answers

May 5, 2009 at 10:28 AM


hello,
you have to change the datatype of the field in which you are inserting your text area
content. if you are using mysql then put the datatype as "longtext".

repply your feedback.


May 5, 2009 at 11:33 AM


Hi Friend,

Try the following code:

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

class Form extends JFrame {
Form() {
JLabel label = new JLabel();
label.setText("Enter Description:");
JButton ADD=new JButton("Insert");
final JTextArea area =new JTextArea(10,25);

final JPanel panel=new JPanel(new GridLayout(2,2));
panel.add(label);
panel.add(area);
panel.add(ADD);

add(panel,BorderLayout.CENTER);
ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value=area.getText();
Connection con = null;
String url = "jdbc:mysql://192.168.10.126/";;
String db = "roseindia";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
Statement st = con.createStatement();
int i= st.executeUpdate("Insert into Description(description) values('"+value+"')");
JOptionPane.showMessageDialog(null,"Data is successfully inserted into the database." );
st.close();
con.close();
}
catch(Exception e){
System.out.println(e);
}
}
});
}
}
class InsertTextArea{
public static void main(String arg[]) {
try {
Form frame=new Form();
frame.setSize(300,100);
frame.setVisible(true);
}
catch(Exception e) {}
}
}
You have to put the 'text' or 'longtext' datatype for the textarea field in the database table.

Thanks









Related Tutorials/Questions & Answers:
ERRor in executing DB program
ERRor in executing DB program  While executing following code an Error was generated.can any one help me for this. LiveDB liveDBObj...=pstmt.executeUpdate(qry); ---------- **ERROR:java.sql.SQLException: You have
Zend Db error - WebSevices
Zend Db error  Hello friends, How i get the values from the database using zend framework Any one know the code. Help me
Advertisements
db error - Java Beginners
db error  Hi, how to insert text area content into database...://192.168.10.126/"; String db = "roseindia"; String driver = "com.mysql.jdbc.Driver...(driver); con = DriverManager.getConnection(url+db, user, pass
DB Insert
DB Insert  How to insert XML data into a database column? Column data type is CLOB
db
db
db connectivity
db connectivity  hi i am beginner in objective c lang and having knowlwgde of basic syntax of this lang and need statements that can be used to connect to sqlite. please do send me the simple example code. i am using GNUstep
DB connectivity - EJB
DB connectivity  DB connectivity
no data in db
no data in db  Using the example in "Networking/web-services-database.shtml" managed to do everything as shown above but there is no data in the database. the result is "record inserted". where can the error
getting db in action class
getting db in action class  hi, Am usin struts in ma application... n i need to interact with the db .. so i used.. getDataSource(request) but it gives me an error.. java.lang.NoSuchMethodError: LoginAction.getDataSource(Ljavax
Aggregrate function Max() in db
and stuck with this problem. i have a table like Brand in mySql db where brandid(varchar) is generating automatically.. im having a Db connection class and a method... (SQLException sq) { System.out.println("error" + sq); return "error
j2me with derby db - MobileApplications
j2me with derby db  Hello, Presently Iam working on the j2me(wireless toolkit2.0).I have done so many applns in j2me,but I want to install derby db in j2me.I am new to derbydb. Can u tell me briefly abt derby db,which version
about db - Struts
About DB in Struts  I have one problem about database. i am using netbeans serveri glassfish. so which is the data source struts config file should be? Please help me
error
error  while iam compiling iam getting expected error
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
JSP,DB,SERVLET
JSP,DB,SERVLET  I have a jsp page with 3 text fields name,age ,city.i populated these datas into a database table.I have another jsp page with 4 fields name, city , age and phone.Once the user enter the name, city and age should
Server DB connection - JDBC
Server DB connection  Hello Guys I want to connect two databases at the same time but it looks like the java is only picking up the second database. One database is on my localhost and the other one is on server, I want
JSP,DB,SERVLET
JSP,DB,SERVLET  I have a jsp page called page1.jsp with 3 text fields name,phone ,city.i populated these datas into a database table through servlet...) { request.setAttribute("Error", e.getMessage()); rd
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
how to migrate java db to mysql
how to migrate java db to mysql  I have an aplication,for migrating java db to mysql db.how it will done
DB Schema Viewer
DB Schema Viewer       DB Schema Viewer is an Eclipse plugin that builds a graphical view of an existing database. Reverse Engineering is performed through JDBC
fat image from db
fat image from db   <%@ page import="java.sql.*"%> <%@ page import="java.io.*"%> <% Blob image = null; Connection con = null; byte[] imgData = null ; Statement stmt
fat image from db
fat image from db   <%@ page import="java.sql.*"%> <%@ page import="java.io.*"%> <% Blob image = null; Connection con = null; byte[] imgData = null ; Statement stmt
fat image from db
fat image from db   <%@ page import="java.sql.*"%> <%@ page import="java.io.*"%> <% Blob image = null; Connection con = null; byte[] imgData = null ; Statement stmt
fat image from db
fat image from db   <%@ page import="java.sql.*"%> <%@ page import="java.io.*"%> <% Blob image = null; Connection con = null; byte[] imgData = null ; Statement stmt
error
error
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version. This type error also comes when java file
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
Tutorials   
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads