Home Discussion Discuss: Creating a MySQL Database Table to store Java Types

  • INSERCION DE DATOSjavier May 30, 2011 at 12:10 AM

    Buenas fijense que pues intento insertar mas datos a mi base de datos y pues solo me dice que estoy violando la llave primaria y que la estoy duplicando alguien me puede decir que hacer este es el codigo que utilizo String conexion = "jdbc:mysql://localhost/cierre?" + "User= root & Password ="; Connection conecta; try{ conecta = (Connection)DriverManager.getConnection(conexion,"root","Francisco"); String in ="CREATE TABLE IF NOT EXISTS cliente(id int, " + "Nombre varchar(30), Apellido varchar(30), PRIMARY KEY (id));"; Statement st= null; st = (Statement)conecta.createStatement(); JOptionPane.showMessageDialog(null,"rs creado \n"); int n = st.executeUpdate(in); String con = "SELECT * FROM cliente"; Statement st2 = (Statement)conecta.createStatement(); ResultSet rs2= st2.executeQuery(con); ResultSetMetaData metadat = rs2.getMetaData(); int numerocol=metadat.getColumnCount(); for (int i=1; i<numerocol; i++) { JOptionPane.showMessageDialog(null, metadat.getCatalogName(i)+"\t"); } while (rs2.next()) { for (int i =1; i<numerocol; i++) { JOptionPane.showMessageDialog(null, rs2.getObject(i)); } } }catch(SQLException e) { JOptionPane.showMessageDialog(null, "Exception en BD:"+e.toString()); } } }

  • thanksBarbara September 18, 2011 at 6:26 PM

    Thanks, helped a lot!)

  • ResultSetMetaData INSERCION DE DATOS May 30, 2011 at 7:39 AM

    Look how good they try to insert more data into my database and it just tells me that I am violating the primary key and that I'm duplicating someone can tell me to do this is the code I use: String conexion = "jdbc:mysql://localhost/cierre?" + "User= root & Password ="; Connection conecta; try{ conecta = (Connection)DriverManager.getConnection(conexion,"root","Francisco"); String in ="CREATE TABLE IF NOT EXISTS cliente(id int, " + "Nombre varchar(30), Apellido varchar(30), PRIMARY KEY (id));"; Statement st= null; st = (Statement)conecta.createStatement(); JOptionPane.showMessageDialog(null,"rs creado \n"); int n = st.executeUpdate(in); String con = "SELECT * FROM cliente"; Statement st2 = (Statement)conecta.createStatement(); ResultSet rs2= st2.executeQuery(con); ResultSetMetaData metadat = rs2.getMetaData(); int numerocol=metadat.getColumnCount(); for (int i=1; i<numerocol; i++) { JOptionPane.showMessageDialog(null, metadat.getCatalogName(i)+"\t"); } while (rs2.next()) { for (int i =1; i<numerocol; i++) { JOptionPane.showMessageDialog(null, rs2.getObject(i)); } } }catch(SQLException e) { JOptionPane.showMessageDialog(null, "Exception en BD:"+e.toString()); } } }

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
JDBC

Creating a MySQL Database Table to store Java Types
Creating a MySQL Database Table to store Java Types... to store a java types in our database table. Now one question may arise in your... to create a table in MySQL database that stores all java types. Here we 

JDBC

Mapping MySQL Data Types in Java
Mapping MySQL Data Types in Java       Data types of MySQL and Java programming language... using MySQL data types and a application using Java data types. We need to provide 

Java-Tutorials

How To Store Image Into MySQL Using Java
How To Store Image Into MySQL Using Java In this section we will discuss about how to store an image into the database using Java and MySQL. This example... using Java. We will use the MySQL database system to store the image 

Java Beginners

How to store image into database
into database using Java. Can anyone help me that how can i store image into database using Java. Thanks in advance.   hi friend, To store image... through the following link How To Store Image Into MySQL Using Java 

JDBC Questions

image store in database - JDBC
; Inserting Image in Database Table http://www.roseindia.net/jdbc/jdbc-mysql/insert... to store image into database. Check at http://www.roseindia.net/servlets/insert...image store in database  Dear Deepak Sir, If I want to store image 

Java Beginners

retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir... table of database... which is stored in mysql. so to apply some arithmetic operation on it we have 

JDBC

Inserting values in MySQL database table
insert values in the MySQL database table. We know that tables store data in rows and column format. After creating a database table, you need to insert... Inserting values in MySQL database table    

JDBC

JDBC Example with MySQL
; Creating a MySQL Database Table to store Java Types Dear user, consider a case where we need to store a java types in our database table. This section describes how to create a MySQL database table that stores all java types 

JDBC

Inserting Image in Database Table
to the MySQL database table.  Flow of the process : This program helps the user to insert an image in the MySQL database table. To insert... Inserting Image in Database Table    

Java Beginners

store data from a variable in mysql?
store data from a variable in mysql?  sir last time asked you tell me how to retrieve data from a database mysql and store it in an int variable... of the calculation from an int variable into mysql in a new table of database. how 

JDBC

Copy Table in a MySQL Database
Copy Table in a MySQL Database     ... in a same MySQL database. Description of Code: This program helps you in copying one table to another in a same MySQL database. To copy any table,  firstly 

JSP Servlet Questions

how to store image upload path to mssql database
the file path to database. 1)form.jsp: <%@ page language="java" %> <...how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use 

JSP Servlet Questions

how to store image upload path to mssql database
the file path to database. 1)form.jsp: <%@ page language="java" %> <...how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use 

JSP Servlet Questions

how to store image upload path to mssql database
the file path to database. 1)form.jsp: <%@ page language="java" %> <...how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use 

JSP Servlet Questions

how to store image upload path to mssql database
the file path to database. 1)form.jsp: <%@ page language="java" %> <...how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use 

JSP Servlet Questions

how to import excel sheet into mysql database and save it as a table in database
how to import excel sheet into mysql database and save it as a table in database  sir, i want to import an excel sheet into a MySQL database and after importing it i want to store the excel sheet as a table in database 

JDBC

Description of Database Table
, pass the table name in the database query and use some java methods to get... Description of Database Table     ... about the database table. As we all know that, table has some specific information 

Java Beginners

Store image from html img tag into mysql db using java
Store image from html img tag into mysql db using java  Hi. How to get the image displayed in the < img > tag of HTML and store it in the mysql database using java? Thanks in advance 

MySQL

MySQL Create Table
MySQL Create Table       Here, you will read the brief description about the MySQL create table. The CREATE TABLE statement is used for creating a table in database.  

JDBC

Connecting to a MySQL Database in Java
Connecting to a MySQL Database in Java   ... will learn how to connect the MySQL database with the Java file. Firstly, we need...: This program establishes the connection between MySQL database and java files 

Java Beginners

Storing records of a file inside database table in java
Storing records of a file inside database table in java  Here is my... and whenever user selects student.csv and clicks on submit button, i have to store the records inside the database except headings (Here sid,sname,age are headings 

JDBC Questions

store and retrive image from database - JDBC
store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image in database using Java. import java.sql.*; import java.io.*; public class 

JSP-Tutorials

Make Unique Column in Database Table
Make Unique Column in Database Table   ... a unique key in a column of a database table. While declaring unique key...;} } Database Table: Student Table Stu_id Stu_name Stu_sub Stu 

MySQL

MySQL Database
such as MySQL, the first step in creating and using a database is to establish its structure... in creating a successful MySQL database connection when using the PHP server model... MySQL Database       MYSQL 

JSP Servlet Questions

Unable to store the image into database
Unable to store the image into database  Hello, I have created below... ###################################### CREATE TABLE IMAGEMAIN(ID INTEGER,IMAGE BLOB) ; ################## HTML Form...); }   Hi, Please check the thread How to Insert image into database 

JSP Tutorials

Create a Table in Mysql database through SQL Query in JSP
; This is detailed java code to connect a jsp page to mysql database and create a table of given... Create a Table in Mysql database through SQL Query in JSP...;head> <title>Create table in mysql database using jsp< 

SQL Question

Database
Database  i want to store the uploaded video and image for this which datatype we want to use in creation of the table in MySQL   You have to use 'longblob' datatype CREATE TABLE `file 

HTML Questions

how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION 

JDBC

Deleting a Table from Database
database. But how we can delete the table using java methods and API. In this section we are describing, how to delete a table from database using java methods. Java provides the facility for deleting a specific table from a given database 

JDBC

Creating a Database Table
Creating a Database Table     ... and it's description that helps you to create a database table by using java file. Brief... are going to establish the connection with database and creating a table 

DMCA.com