Wednesday 28 August 2013

How to insert dynamic Image Path in Mysql using Javafxml

Hiii Here i have taken two text Field and one ImageView .now i have taken dynamic image from Filechooser and then store it into MySql database.




 s1=t1.getText();
             s2=t2.getText();
             s3=l1.getText();
            // img1.getProperties();
           
        {
            try{

            Class.forName("com.mysql.jdbc.Driver").newInstance();

        }catch(ClassNotFoundException cnfe){

            System.err.println("Error: "+cnfe.getMessage());

        }catch(InstantiationException ie){

            System.err.println("Error: "+ie.getMessage());

        }catch(IllegalAccessException iae){

            System.err.println("Error: "+iae.getMessage());

        }
           try
           {
            Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/farhan","root","root" );
              String query="insert into Product_Detail(Prod_No,Prod_Name,Picture)values(?,?,?)";
         
           System.out.println("hiiiiiii man54");
           PreparedStatement ps=conn.prepareStatement(query);
           System.out.println("hiiiiiii man32");
           ps.setString(1,s1);
        ps.setString(2, s2);
        ps.setString(3,s3);
       int i = ps.executeUpdate();
         
           }
           catch(Exception e)
           {
             
                 e.printStackTrace();
           }
         
           System.out.println("database");
           if(i==1)
           {
               System.out.println("database count 1");
             
               System.out.println("Successfully inserted");
           }
           else
           {
               System.out.println("Incorrect Syntac");
           }

No comments:

Post a Comment