i want to insert a mp4 vedio into sqlserver can any one help me
import java.sql.*; import java.io.*; class InsertVideo { public static void main(String[] args) throws SQLException { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); File file = new File("c:/new.mp4"); PreparedStatement psmnt = connection.prepareStatement("insert into myfile(name, file) "+ "values(?,?)"); psmnt.setString(1,file.getName()); FileInputStream fis = new FileInputStream(file); psmnt.setBinaryStream(2, (InputStream)fis, (int)(file.length())); int s = psmnt.executeUpdate(); System.out.println("Inserted Successfully"); connection.close(); psmnt.close(); } catch (Exception ex) { System.out.println("Found some error : "+ex); } } }
thank u so much
Ads