Bug #42318 com.mysql.jdbc source
Submitted: 24 Jan 2009 1:37 Modified: 24 Jan 2009 2:03
Reporter: pqc 4391 Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S5 (Performance)
Version:5.1.7 OS:Linux
Assigned to: CPU Architecture:Any

[24 Jan 2009 1:37] pqc 4391
Description:
public void UpdateSql(String xmlfile,String xpathstr)
  {
   Document dataDoc = null; //?????????Document
  Document newDoc = null; //?????????????xml
   String sql="";
Connection conn1=null;
  Statement statement=null;
  try
  {
   DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
   DocumentBuilder docbuilder = dbfactory.newDocumentBuilder();
   dataDoc = docbuilder.newDocument();
   newDoc = docbuilder.newDocument();
    Document sqldoc=getDoc(xmlfile);

       
ConnectionPool cf = null;
  cf=this.dbcf; 

       conn1=cf.getConnection();
 
      statement = conn1.createStatement(); //ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE
          String sqlstr[]=getNodeValues(sqldoc,xpathstr);
    
           for(int i=0;i<sqlstr.length;i++)
           {
	      sql=sqlstr[i].toString();
              statement.execute(sql);
           }
          String insertsql="insert into userdlxx(userdm,userdlm,userpwd)  values('wwwadmin','wwwadmin','"+strDegist("123456")+"')";
int sqln=statement.executeUpdate(insertsql);
    
  }
 catch(Exception e)
  {
   System.out.println("create document error......");
   
   e.printStackTrace();
  }	
  finally
  {
   if(conn1 != null)
   {
    try 
    {
      statement.close();
      conn1.close();
    } catch (SQLException e) 
    {
     // TODO Auto-generated catch block
     System.out.println("can't close connection..........");
     e.printStackTrace();
    }
   }
  }	
   }

How to repeat:
//******initsql**********/
use wwwdatatmp;
delimiter //
create trigger uppzxh before insert on jzkxjpz for each row begin set @tmpn1=(select max(pzxh) from jzkxjpz where date(sqrq)=date(now())); if @tmpn1 is null then set new.pzxh=concat(replace(date(now()),'-',''),'0001'); else set new.pzxh=@tmpn1+1; end if; end;  //
delimiter ;
//***error**///
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'source initdb.sql' at line 1
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        at com.mysql.jdbc.Util.getInstance(Util.java:381)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2477)
        at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:741)
        at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:587)
        at wwwinitdb.UpdateSql(wwwinitdb.java:131)
[24 Jan 2009 2:03] Mark Matthews
You're using syntax that only the mysql command-line client understands, i.e. "delimiter" and "source". Client libraries do not process these commands, nor does mysql server.

You'll need to find some other way to parse and process these lines.