Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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



Advertisement
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
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
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
JSP,DB,SERVLET
JSP,DB,SERVLET  hi thank you for your reply.With this code i can insert the data successfully into database but In ajax.jsp once i give the name;;;age and city are not automatically fetched......instead sumthing get filled
 

 

 

DMCA.com