gpt4 book ai didi

java 如何使用 JDBC 执行 SQL Dump 数据

转载 作者:行者123 更新时间:2023-11-30 00:08:49 24 4
gpt4 key购买 nike

我在使用普通 JBDC 连接执行 sql 转储数据时遇到错误,我不知道出现错误的原因是什么:请帮我。

   try{
Connection con1=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
String sql1=jTextArea1.getText();
PreparedStatement stm1=(PreparedStatement) con1.prepareStatement(sql1);
stm1.executeUpdate(sql1);

}
catch (Exception e) {
System.out.println(e.getMessage());
}

jTextarea1 中的数据:

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `admission`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `admission` (
`sno` int(11) NOT NULL,
`srno` varchar(255) NOT NULL,
`studentname` varchar(30) DEFAULT NULL,
`dob` varchar(255) DEFAULT NULL,
`gender` varchar(20) DEFAULT NULL,
`cast` varchar(10) DEFAULT NULL,
`Religion` varchar(15) DEFAULT NULL,
`mothername` varchar(30) DEFAULT NULL,
`motheroccupation` varchar(30) DEFAULT NULL,
`fathername` varchar(30) DEFAULT NULL,
`fatheroccupation` varchar(30) DEFAULT NULL,
`localguardian` varchar(30) DEFAULT NULL,
`Address` varchar(35) DEFAULT NULL,
`phone` bigint(10) DEFAULT NULL,
`anotherno` bigint(10) DEFAULT NULL,
`Nationality` varchar(255) DEFAULT NULL,
`dateofadm` varchar(255) DEFAULT NULL,
`Last_institution` varchar(255) DEFAULT NULL,
`class` varchar(10) DEFAULT NULL,
`sec` varchar(10) DEFAULT NULL,
`admfees` double(10,2) DEFAULT NULL,
`conv` varchar(10) DEFAULT NULL,
`convamt` double(10,2) DEFAULT NULL,
`feeschedule` varchar(10) DEFAULT NULL,
`yearlyfee` double(10,2) DEFAULT NULL,
`pre_bal` double(10,2) DEFAULT '0.00',
`sphoto` longblob NOT NULL,
`bicycle` double(10,2) DEFAULT NULL,
`session` varchar(255) DEFAULT NULL,
`lastupdatedon` varchar(255) NOT NULL DEFAULT ' ',
`monfee` int(11) DEFAULT NULL,
`tcharge` int(11) DEFAULT NULL,
`othercharge` int(11) DEFAULT NULL,
`tcn` varchar(255) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `admission` WRITE;
/*!40000 ALTER TABLE `admission` DISABLE KEYS */;
/*!40000 ALTER TABLE `admission` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `bank1`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank1` (
`sno` int(11) NOT NULL,
`date` varchar(255) DEFAULT NULL,
`amt` int(11) DEFAULT NULL,
`personby` varchar(225) DEFAULT NULL,
`netamt` int(11) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `bank1` WRITE;
/*!40000 ALTER TABLE `bank1` DISABLE KEYS */;
/*!40000 ALTER TABLE `bank1` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `bank2`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank2` (
`sno` int(11) NOT NULL,
`date` varchar(255) DEFAULT NULL,
`amt` int(11) DEFAULT NULL,
`personby` varchar(225) DEFAULT NULL,
`netamt` int(11) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `bank2` WRITE;
/*!40000 ALTER TABLE `bank2` DISABLE KEYS */;
/*!40000 ALTER TABLE `bank2` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `bank3`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank3` (
`sno` int(11) NOT NULL,
`date` varchar(255) DEFAULT NULL,
`amt` int(11) DEFAULT NULL,
`personby` varchar(225) DEFAULT NULL,
`netamt` int(11) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `bank3` WRITE;
/*!40000 ALTER TABLE `bank3` DISABLE KEYS */;
/*!40000 ALTER TABLE `bank3` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `cashadd`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `cashadd` (
`sno` int(11) NOT NULL,
`srno` int(11) DEFAULT NULL,
`sname` varchar(255) DEFAULT NULL,
`amt` int(11) DEFAULT NULL,
`date` varchar(255) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `cashadd` WRITE;
/*!40000 ALTER TABLE `cashadd` DISABLE KEYS */;
/*!40000 ALTER TABLE `cashadd` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `cashinhand`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `cashinhand` (
`cash` double(10,2) DEFAULT NULL,
`cashbook` varchar(255) NOT NULL DEFAULT '',
`sno` int(11) DEFAULT NULL,
PRIMARY KEY (`cashbook`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `cashinhand` WRITE;
/*!40000 ALTER TABLE `cashinhand` DISABLE KEYS */;
INSERT INTO `cashinhand` VALUES (0.00,'Head cash book #',1),(0.00,'Main Cash book $',2),(0.00,'P. cash Book *',3);
/*!40000 ALTER TABLE `cashinhand` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `emp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp` (
`empid` int(11) NOT NULL,
`empname` varchar(255) DEFAULT NULL,
`empCategory` varchar(255) DEFAULT NULL,
`fathername` varchar(255) DEFAULT NULL,
`gender` varchar(255) DEFAULT NULL,
`Address` varchar(255) DEFAULT NULL,
`phoneno` bigint(11) DEFAULT NULL,
`Qualification` varchar(255) DEFAULT NULL,
`Experience` varchar(255) DEFAULT NULL,
`Date` varchar(255) DEFAULT NULL,
`Salary` int(11) DEFAULT NULL,
PRIMARY KEY (`empid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `emp` WRITE;
/*!40000 ALTER TABLE `emp` DISABLE KEYS */;
/*!40000 ALTER TABLE `emp` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `empcategory`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `empcategory` (
`Category` varchar(255) NOT NULL DEFAULT '',
`sno` int(11) DEFAULT NULL,
PRIMARY KEY (`Category`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `empcategory` WRITE;
/*!40000 ALTER TABLE `empcategory` DISABLE KEYS */;
/*!40000 ALTER TABLE `empcategory` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `emppay`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emppay` (
`sno` int(11) NOT NULL,
`date` varchar(255) DEFAULT NULL,
`empname` varchar(255) DEFAULT NULL,
`empid` int(11) DEFAULT NULL,
`amt` int(11) DEFAULT NULL,
`empcategory` varchar(255) DEFAULT NULL,
`leave1` int(11) DEFAULT NULL,
`netamt` double(10,3) DEFAULT NULL,
`work` int(11) DEFAULT NULL,
`pf` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `emppay` WRITE;
/*!40000 ALTER TABLE `emppay` DISABLE KEYS */;
/*!40000 ALTER TABLE `emppay` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `feesdeposite`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feesdeposite` (
`studid` varchar(255) DEFAULT NULL,
`Sno` int(11) DEFAULT NULL,
`receiptno` varchar(255) NOT NULL DEFAULT '0',
`date` varchar(255) DEFAULT NULL,
`name` varchar(30) DEFAULT NULL,
`class_Sec` varchar(15) DEFAULT NULL,
`month` varchar(15) DEFAULT NULL,
`noofmonth` int(2) DEFAULT NULL,
`prebalance` double(10,2) DEFAULT NULL,
`monthlyfees` int(5) DEFAULT NULL,
`termcharges` int(5) DEFAULT NULL,
`conv` int(5) DEFAULT NULL,
`other` int(5) DEFAULT NULL,
`extra` int(5) DEFAULT NULL,
`Total` int(6) DEFAULT NULL,
`Recieve` int(6) DEFAULT NULL,
`balance` int(6) DEFAULT NULL,
`lastmonth` int(11) DEFAULT NULL,
`session` varchar(255) DEFAULT NULL,
`lastbaldepo` varchar(255) DEFAULT NULL,
`bich` int(11) DEFAULT NULL,
`fine` int(11) DEFAULT NULL,
`finer` varchar(255) DEFAULT NULL,
`concr` varchar(255) DEFAULT NULL,
`paidconv` int(11) DEFAULT NULL,
`convamt` int(11) DEFAULT NULL,
PRIMARY KEY (`receiptno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `feesdeposite` WRITE;
/*!40000 ALTER TABLE `feesdeposite` DISABLE KEYS */;
/*!40000 ALTER TABLE `feesdeposite` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `feesschedule`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feesschedule` (
`sno` int(8) NOT NULL DEFAULT '0',
`date` varchar(255) DEFAULT NULL,
`month` int(11) DEFAULT NULL,
`noofmonth` int(2) DEFAULT NULL,
`fees` varchar(6) DEFAULT NULL,
`conv` varchar(6) DEFAULT NULL,
`termcharges` varchar(6) DEFAULT NULL,
`sname` varchar(255) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `feesschedule` WRITE;
/*!40000 ALTER TABLE `feesschedule` DISABLE KEYS */;
INSERT INTO `feesschedule` VALUES (1,'1 to 10',1,1,'Yes','Yes','No','Type-A'),(2,'1 to 10',2,2,'Yes','Yes','No','Type-A'),(3,'1 to 10',4,1,'Yes','Yes','No','Type-A'),(4,'1 to 10',5,1,'Yes','Yes','Yes','Type-A'),(5,'1 to 10',6,2,'Yes','Yes','No','Type-A'),(6,'1 to 10',7,1,'Yes','Yes','Yes','Type-A'),(7,'1 to 10',8,2,'Yes','Yes','No','Type-A'),(8,'1 to 10',9,2,'Yes','Yes','No','Type-A'),(9,'1 to 10',4,1,'Yes','Yes','No','Type-B'),(10,'1 to 10',5,1,'Yes','Yes','Yes','Type-B'),(11,'1 to 10',6,2,'Yes','Yes','No','Type-B'),(12,'1 to 10',7,1,'Yes','Yes','Yes','Type-B'),(13,'1 to 10',8,2,'Yes','Yes','No','Type-B'),(14,'1 to 10',9,2,'Yes','Yes','No','Type-B'),(15,'1 to 10',10,2,'Yes','Yes','No','Type-B'),(16,'1 to 10',11,1,'Yes','Yes','No','Type-B'),(17,'1 to 10',1,1,'Yes','Yes','No','Type-C'),(18,'1 to 10',2,2,'Yes','Yes','No','Type-C'),(19,'1 to 10',4,1,'Yes','Yes','No','Type-C'),(20,'1 to 10',5,1,'Yes','Yes','Yes','Type-C'),(21,'1 to 10',6,1,'Yes','Yes','No','Type-C'),(22,'1 to 10',7,1,'Yes','Yes','Yes','Type-C'),(23,'1 to 10',8,1,'Yes','Yes','No','Type-C'),(24,'1 to 10',9,1,'Yes','Yes','No','Type-C'),(25,'1 to 10',10,1,'Yes','Yes','No','Type-C'),(26,'1 to 10',11,1,'Yes','Yes','No','Type-C'),(27,'1 to 10',12,1,'Yes','Yes','No','Type-C'),(52,'1 to 10',1,3,'Yes','Yes','No','TYPE-D'),(53,'1 to 10',4,3,'Yes','Yes','Yes','TYPE-D'),(54,'1 to 10',7,3,'Yes','Yes','Yes','TYPE-D'),(55,'1 to 10',10,3,'Yes','Yes','No','TYPE-D');
/*!40000 ALTER TABLE `feesschedule` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `feesstructure`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feesstructure` (
`session` varchar(15) NOT NULL DEFAULT '',
`prospectusfees` double(10,2) DEFAULT NULL,
`registration` double(10,2) DEFAULT NULL,
`adm` double(10,2) DEFAULT NULL,
`comp` double(10,2) DEFAULT NULL,
`digital1to8` double(10,2) DEFAULT NULL,
`digitalpgtoprep` double(10,2) DEFAULT NULL,
`generator` double(10,2) DEFAULT NULL,
`cycle` double(10,2) DEFAULT NULL,
`termcharges` double(10,2) DEFAULT NULL,
PRIMARY KEY (`session`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `feesstructure` WRITE;
/*!40000 ALTER TABLE `feesstructure` DISABLE KEYS */;
INSERT INTO `feesstructure` VALUES ('14-15',200.00,200.00,1000.00,400.00,1200.00,1000.00,0.00,0.00,580.00);
/*!40000 ALTER TABLE `feesstructure` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `head`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `head` (
`headname` varchar(255) NOT NULL,
`sno` int(11) DEFAULT NULL,
`amt` int(11) DEFAULT NULL,
PRIMARY KEY (`headname`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `head` WRITE;
/*!40000 ALTER TABLE `head` DISABLE KEYS */;
/*!40000 ALTER TABLE `head` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `headpayment`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `headpayment` (
`date` varchar(255) DEFAULT NULL,
`sno` int(11) NOT NULL DEFAULT '0',
`payhead` varchar(255) DEFAULT NULL,
`advance` int(6) DEFAULT NULL,
`balance` int(6) DEFAULT NULL,
`net` int(6) DEFAULT NULL,
`comment` varchar(255) DEFAULT NULL,
`cashbook` varchar(255) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `headpayment` WRITE;
/*!40000 ALTER TABLE `headpayment` DISABLE KEYS */;
/*!40000 ALTER TABLE `headpayment` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `login`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `login` (
`id` varchar(255) NOT NULL,
`password` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `login` WRITE;
/*!40000 ALTER TABLE `login` DISABLE KEYS */;
INSERT INTO `login` VALUES ('gacme','gacme'),('jacme','jacme');
/*!40000 ALTER TABLE `login` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `money_detailer`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `money_detailer` (
`sno` int(11) NOT NULL,
`date` date DEFAULT NULL,
`income` varchar(255) DEFAULT NULL,
`iamt` varchar(255) DEFAULT NULL,
`expences` varchar(255) DEFAULT NULL,
`eamt` varchar(255) DEFAULT NULL,
`net` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `money_detailer` WRITE;
/*!40000 ALTER TABLE `money_detailer` DISABLE KEYS */;
/*!40000 ALTER TABLE `money_detailer` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `monthlyfees`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `monthlyfees` (
`session` varchar(15) NOT NULL DEFAULT '',
`pg` int(6) DEFAULT NULL,
`nursury` int(6) DEFAULT NULL,
`prep` int(6) DEFAULT NULL,
`1st` int(6) DEFAULT NULL,
`2nd` int(6) DEFAULT NULL,
`3rd` int(6) DEFAULT NULL,
`4th` int(6) DEFAULT NULL,
`5th` int(6) DEFAULT NULL,
`6th` int(6) DEFAULT NULL,
`7th` int(6) DEFAULT NULL,
`8th` int(6) DEFAULT NULL,
`9th` int(6) DEFAULT NULL,
`10th` int(6) DEFAULT NULL,
`11th` int(6) DEFAULT NULL,
`12th` int(6) DEFAULT NULL,
PRIMARY KEY (`session`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `monthlyfees` WRITE;
/*!40000 ALTER TABLE `monthlyfees` DISABLE KEYS */;
INSERT INTO `monthlyfees` VALUES ('14-15',540,540,540,560,560,580,630,660,660,750,750,1125,1200,0,0);
/*!40000 ALTER TABLE `monthlyfees` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `otherpro`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `otherpro` (
`sno` int(11) NOT NULL,
`studid` varchar(255) DEFAULT NULL,
`studname` varchar(255) DEFAULT NULL,
`product_name` varchar(255) DEFAULT NULL,
`price` double(10,2) DEFAULT NULL,
`date` varchar(255) DEFAULT NULL,
`session` varchar(255) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `otherpro` WRITE;
/*!40000 ALTER TABLE `otherpro` DISABLE KEYS */;
/*!40000 ALTER TABLE `otherpro` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `pendingfee`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pendingfee` (
`date` varchar(255) DEFAULT NULL,
`srno` varchar(255) DEFAULT NULL,
`studentname` varchar(255) DEFAULT NULL,
`calsssesc` varchar(255) DEFAULT NULL,
`receptno` varchar(255) DEFAULT NULL,
`prebal` int(11) DEFAULT NULL,
`cahdepo` int(11) DEFAULT NULL,
`balance` int(11) DEFAULT NULL,
`sno` int(11) NOT NULL DEFAULT '0',
`session` varchar(255) DEFAULT NULL,
`rec` int(11) DEFAULT NULL,
`tot` int(11) DEFAULT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `pendingfee` WRITE;
/*!40000 ALTER TABLE `pendingfee` DISABLE KEYS */;
/*!40000 ALTER TABLE `pendingfee` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `register`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `register` (
`num` int(11) DEFAULT NULL,
`tnum` int(11) DEFAULT NULL,
`date` date NOT NULL DEFAULT '0000-00-00',
PRIMARY KEY (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `register` WRITE;
/*!40000 ALTER TABLE `register` DISABLE KEYS */;
INSERT INTO `register` VALUES (1,25,'2014-04-22'),(0,25,'2014-05-22');
/*!40000 ALTER TABLE `register` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `session`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `session` (
`session_name` varchar(255) NOT NULL,
`sno` int(11) DEFAULT NULL,
PRIMARY KEY (`session_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `session` WRITE;
/*!40000 ALTER TABLE `session` DISABLE KEYS */;
INSERT INTO `session` VALUES ('14-15',1);
/*!40000 ALTER TABLE `session` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `trans`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trans` (
`transport` varchar(255) NOT NULL DEFAULT '',
`sno` int(11) DEFAULT NULL,
`descp` varchar(255) DEFAULT NULL,
PRIMARY KEY (`transport`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

LOCK TABLES `trans` WRITE;
/*!40000 ALTER TABLE `trans` DISABLE KEYS */;
INSERT INTO `trans` VALUES ('Bus',1,''),('Van',2,'');
/*!40000 ALTER TABLE `trans` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

我收到错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COL' at line 2

请帮助我为什么会收到此错误以及我应该如何修复此错误

最佳答案

将 sql1 与 ';' 分开作为

String[] sqlArray = sql1.split(";");

然后在循环中单独执行每个语句

for(String s in sqlArray) {
PreparedStatement stm1=(PreparedStatement) con1.prepareStatement(s);
stm1.executeUpdate(s);
}

关于java 如何使用 JDBC 执行 SQL Dump 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24269641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com