Parsing a log file and inserting into mySQL DB : <p>I am currently tasked with writing up a script which will parse through our log file of mySQL errors and exceptions, and then insert them into a database.</p>

<p>The general format of the log file is:</p>

<pre><code>POSPER ERRORS: 
01 Jan 2014 11:33:23,931 ERROR LazyInitializationException:42 - failed to lazily initialize a collection of role: org.data.moredata.CashRegister.tickets, no session or session was closed
</code></pre>

<p>There are many more lines, but this is just an example of how the error log is currently formatted.The posper errors header only appears once, and subsequent lines are simply more errors.</p>

<p>What I need to do with this script is insert errors into the table I have created with the fields: client_name, timestamp, error_message and error_from (either Posper or a something else. In the example above it is posper). </p>

<p>So how exactly am I supposed to break down the data on each line, assign it to individual mySQL fields, and then insert it into the database? Keep in mind the log file will have many lines, so it will have to execute multiple times. I have already set up the table with the appropriate fields.</p>

<p>Any help would be greatly appreciated. </p>
