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



Home Answers Viewqa JDBC mysql problem
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


paparao
mysql problem
2 Answer(s)      5 years and 3 months ago
Posted in : JDBC



Advertisement
View Answers

September 2, 2009 at 10:26 AM


hai friends myself posted this question but i have refer some books and get some idea. i have verify it practically it i.e


use longblob instead of blob at the time of creation of table in mysql. it will take any image and store in database.


thanks friends


September 3, 2009 at 10:45 AM


Hi Friend,

Create a database table image(id(bigint),image(longblob)) and try the following code:

<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>

<%
String connectionURL = "jdbc:mysql://localhost:3306/test";;;
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(connectionURL, "root", "root");
PreparedStatement ps = con.prepareStatement("INSERT INTO image VALUES(?,?)");
File file = new File("C://spring-wedding-flowers.jpg";);
FileInputStream fs = new FileInputStream(file);
ps.setInt(1,4);
ps.setBinaryStream(2,fs,fs.available());
int i = ps.executeUpdate();
ps.close();
con.close();
}
catch(Exception e){
out.println(e);
}
%>

Thanks


Related Tutorials/Questions & Answers:
mysql problem - JDBC
mysql problem   hai friends i have some problem with image storing in mysql. i.e while i am using image(blob) for insert the image it says... of creation of table in mysql. it will take any image and store in database
MySql date problem
MySql date problem  with a mysql query, how can you get records of previous week dynamically, starting from sunday and ending on saturday? I don't want records from current date, just the previous week
Advertisements
mysql installation problem - JDBC
mysql installation problem  Hi, when i installing mysql server on my pc in MySQL Server Instance Configuration Wizard,I enter the root pw... information. http://www.roseindia.net/mysql/mysql5/Installing-MySQL-on-Windows.shtml
mysql 4.x to 5.x upgrade problem
mysql 4.x to 5.x upgrade problem  mysql 4.x to 5.x upgrade problem
mysql problem - JDBC
mysql problem  hai friends please tell me how to store the videos in mysql plese help me as soon as possible thanks in advance   ... = "jdbc:mysql://localhost:3306/test"; Connection con=null; try
Charset problem upon publishing PHP + MySQL website
Charset problem upon publishing PHP + MySQL website  Charset problem upon publishing PHP + MySQL website
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... have no problem in saving the image in the folder, my problem is it can't save the record to mysql database. heres my code... index.jsp <%@ page
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... have no problem in saving the image in the folder, my problem is it can't save the record to mysql database. heres my code... index.jsp <%@ page language
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database
problem connect jsp and mysql - JSP-Servlet
problem connect jsp and mysql  hello, im getting an error while connecting jsp and mysql. I have downloaded the driver mysql-connector... Software Foundation\Tomcat 5.5\common\lib\mysql-connector-java-2.0.14.jar
problem in selecting second arraylist from mysql database
problem in selecting second arraylist from mysql database  Hi... in mysql database. In the below program , i have hard-coded that second list... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); Statement stmt
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database  Hi everyone i would like to ask few question here,since i try to configure this out for 1 week,i dont find any solution for my problem
MYSQL
MYSQL  How to create time and date based trigger in mysql   MySQL Time Trigger
mysql
mysql  how to open\import table in .dbf format in mysql
MySql
MySql  what is default password of mySql, and how i configure mySql.   Hi, If you are installing MySQL on windows then you will have to provide the Password for the user root at the installation time. You may try
mysql
you need to download the mysql-connector jar file for connecting java program from mysql database.......   Hi friend, MySQL is open source database... is the link for the page from where you can understand how to Download and Install MySQL
mysql
mysql  want the code for mysql nested select query with single where condition.want to select data from more than one table
php problem
php problem  Hello!! I have a problem ,i want to display the data... not connect: ' . mysql_error()); } $sql = 'SELECT * FROM users WHERE username="'.$username.'" LIMIT 1'; $result = mysql_query( $sql); if(! $result) { die('Could
problem on php
problem on php   l have five tables and build them as forms and link between them php and database and i want to build query between them plz help me soon   PHP MySQL Tutorials
MySQL
MySQL In this section we will read about what is MySQL, MySQL distribution, MySQL features, MySQL architecture etc. MySQL unofficially, pronounced as My... the database. The development, distribution, and support of MySQL is done
mysql - SQL
mysql  hi i am using mysql. i want to create simple table... the problem : CREATE TABLE parent (id INT NOT NULL, PRIMARY...=INNODB; For more information MySql visit to : http://www.roseindia.net
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
Mine Problem
Mine Problem  how to view a row from a table created in mysql in a java swing application
uploading problem
about file into database lib. i use navicat Mysql ... i use this code... <...(); } } } } %> my problem...: firstly.... then problem solved... bt real problem is when i upload files fusing mozilla
solve this problem
in table please tell me the solution for thid problem import java.io.*; import..."); PrintWriter out = response.getWriter(); String url = "jdbc:mysql...("text/html"); PrintWriter out = response.getWriter(); String url = "jdbc:mysql
Servlet problem
problem from last three month and now i hope rose india developers... connectivity code it works but problem is with servlet page. My servlet code...;"; Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://127.0.0.1
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter please help me this problem
problem in validation
problem in validation  sir/madam, i m using struts-1.3.10. i m getting a problem my properties file is not found.... while i hav configuired it in struts-config.xml file, like thanks n regards himanshu
Advertisements
 

 

 

DMCA.com