本文介绍了Java jdbc mysql updatequery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好!我试着写一些方法,这将在日期基础上添加一条新记录。 代码:Hello! Im trying to write some method, which will add a new record to date base.Code:public void insertToPlayList() { try { connecting(); stat6 = Connection.createStatement(); stat6.executeUpdate("INSERT INTO odtwarzane VALUES('','2','4','2','2015-10-10','10:10')"); connecting(); } catch (SQLException Exception) { JOptionPane.showMessageDialog(null, "Wystąpił problem z dodaniem rekordu.", "Błąd", JOptionPane.ERROR_MESSAGE); } } 最初,这种方法获得了5个参数,但是为了解决问题,我将其删除了。Originally, this method is getting 5 paramenters, but for fixing problem i removed it.public void insertToPlayList(int filmId, int cinemaId, int priceId, String date, String time) { try { connecting(); stat6 = Connection.createStatement(); String str = ("INSERT INTO odtwarzane (id_of, id_filmu, id_kina, id_ceny, data, godzina) VALUES (," + filmId + ", " + cinemaId + ", " + priceId + ", '" + date + "', '" + time + "');"); stat6.executeUpdate(str); connecting(); } catch (SQLException Exception) { JOptionPane.showMessageDialog(null, "Wystąpił problem z dodaniem rekordu.", "Błąd", JOptionPane.ERROR_MESSAGE); } } 我在PhpMyAdmin上查看了,并且工作表已经完成I checked on PhpMyAdmin, and statment was workedINSERT INTO odtwarzane VALUES('','2','4','2','2015-10-10','10:10'); 无论如何,程序抛出SQLException,我不知道如何解决它。 我尝试了什么: 我试图以多种方式更改语句或代码,我当时在互联网上寻找一些解决方案,但我没有找到它。Anyway, program is throwing SQLException, and i dont know how to fix it.What I have tried:I tried to change statement or code in many ways, and i was looking for some solution in the Internet, but i didnt find it.推荐答案 这篇关于Java jdbc mysql updatequery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-27 06:11
查看更多