I have this error after 20-30 minutes of inactivity
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 2.383.932 milliseconds ago.
The last packet sent successfully to the server was 21.351 milliseconds ago.
I have checked Data Base options,but they are ok
mysql> show session variables like '%timeout%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| table_lock_wait_timeout | 50 |
| wait_timeout | 28800 |
+----------------------------+-------+
10 rows in set (0.00 sec)
mysql> show global variables like '%timeoout%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| table_lock_wait_timeout | 50 |
| wait_timeout | 28800 |
+----------------------------+-------+
10 rows in set (0.00 sec)
Connection class:
public class ConnectionDB {
Connection con;
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://XXXXXXXXXX:3306/";
String nomeutente = "XXXXXXX";
String password = "XXXXXXXX";
String nomedatabase = "XXXXXX";
public Boolean ok = false;
public Connection connect(){
try {
Class.forName(driver);
con = DriverManager.getConnection(url+nomedatabase,nomeutente,password);
ok = true;
return con;
} catch (ClassNotFoundException | SQLException e) {
new ErrorLog();
e.printStackTrace();
ok = false;
return null;
}
}
}
Related
Single-job schedule with two vehicles. One vehicle starts close to the job, the other starts far from the job. Seems it should prefer to use the closer vehicle, as there's a cost-per-distance. But it uses the farther one, if there's a non-zero setCostPerWaitingTime(). Why?
public void testUseCloserVehicleWhenCostsAreSet() throws Exception {
VehicleType type = VehicleTypeImpl.Builder.newInstance("generic")
.setCostPerDistance(0.017753)
//.setCostPerTransportTime(1.0)
.setCostPerWaitingTime(1.0)
.build();
double serviceTime = 420.0;
Location pointA = Location.newInstance(100.0, 100.0);
Location pointB = Location.newInstance(100.0, 200.0);
Location closeToPointA = Location.newInstance(110.0, 110.0);
Location farFromPointA = Location.newInstance(500.0, 110.0);
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder
.newInstance()
.setFleetSize(VehicleRoutingProblem.FleetSize.FINITE)
.addVehicle(VehicleImpl.Builder.newInstance("CloseBy")
.setType(type)
.setStartLocation(closeToPointA)
.build())
.addVehicle(VehicleImpl.Builder.newInstance("FarAway")
.setType(type)
.setStartLocation(farFromPointA)
.build())
.addJob(Shipment.Builder.newInstance("123")
.setPickupLocation(pointA)
.setPickupServiceTime(serviceTime)
.setDeliveryLocation(pointB)
.setDeliveryServiceTime(serviceTime)
.setPickupTimeWindow(new TimeWindow(36000.0, 36360.0))
.setDeliveryTimeWindow(new TimeWindow(36360.0, 36720.0))
.setMaxTimeInVehicle(720.0)
.build())
.build();
VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(vrp)
.buildAlgorithm();
VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(algorithm.searchSolutions());
SolutionPrinterWithTimes.print(vrp, bestSolution, SolutionPrinterWithTimes.Print.VERBOSE);
System.out.flush();
assertEquals("CloseBy", bestSolution.getRoutes().iterator().next().getVehicle().getId());
}
Result:
+----------------------------------------------------------+
| solution |
+---------------+------------------------------------------+
| indicator | value |
+---------------+------------------------------------------+
| costs | 35616.03246830352 |
| noVehicles | 1 |
| unassgndJobs | 0 |
+----------------------------------------------------------+
+--------------------------------------------------------------------------------------------------------------------------------+
| detailed solution |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route | vehicle | activity | job | arrTime | endTime | costs |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 1 | FarAway | start | - | undef | 0 | 0 |
| 1 | FarAway | pickupShipment | 123 | 400 | 36420 | 35607 |
| 1 | FarAway | deliverShipment | 123 | 36520 | 36940 | 35609 |
| 1 | FarAway | end | - | 37350 | undef | 35616 |
+--------------------------------------------------------------------------------------------------------------------------------+
junit.framework.ComparisonFailure:
Expected :CloseBy
Actual :FarAway
I suspect it has something to do with the vehicle arriving at 400 for a job that can't start until 36000. Is there a way to prevent that, so the vehicle starts only as early as needed to reach the first job? Does setCostPerWaitingTime do something other than what I think?
Here's a comparison of the job with only the CloseBy vehicle.
+--------------------------------------------------------------------------------------------------------------------------------+
| detailed solution |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route | vehicle | activity | job | arrTime | endTime | costs |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 1 | FarAway | start | - | undef | 0 | 0 |
| 1 | FarAway | pickupShipment | 123 | 400 | 36420 | 35607 |
| 1 | FarAway | deliverShipment | 123 | 36520 | 36940 | 35609 |
| 1 | FarAway | end | - | 37350 | undef | 35616 |
+--------------------------------------------------------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------------------------------------------------------+
| detailed solution |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route | vehicle | activity | job | arrTime | endTime | costs |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 1 | CloseBy | start | - | undef | 0 | 0 |
| 1 | CloseBy | pickupShipment | 123 | 14 | 36420 | 35986 |
| 1 | CloseBy | deliverShipment | 123 | 36520 | 36940 | 35988 |
| 1 | CloseBy | end | - | 37031 | undef | 35989 |
+--------------------------------------------------------------------------------------------------------------------------------+
I think the problem is that the CloseBy vehicle arrives sooner, so it pays higher wait costs, while the other vehicle is driving during that time so pays less in wait costs. This would be mitigated if the vehicle didn't start until it needed to, but I'm unsure how to set that up.
I create a temp table which consist of several table with UNION ALL statement like here below. I want later map this table to the entity for repository in spring. With other words I wanna map temp table to entity in spring jpa or hibernate.
select * from name UNION ALL
select * from soft where id >3
into temp namesoft_tmp
I tried the following.
select * from namesoft_tmp
but i can't see what is the column which can point me to the conclusion that this is primary key.
What is the unique id(primary key) of table namesoft_tmp?
How can i add auto generated id to temp table?
How can i excute select statement based on unique id?**
In general, the result of a UNION ALL query does not have a primary key; there is no guarantee that there are not duplicate rows in the result set.
Imagine a table describing the table of elements — called elements.
SELECT * FROM elements WHERE atomic_number < 10
UNION ALL
SELECT * FROM elements WHERE symbol MATCHES '[A-F]*'
INTO TEMP union_all;
Here, the elements Boron (B), Carbon (C), Beryllium (Be) and Fluorine (F) are all listed twice.
However, you can use:
SELECT ROWID, * FROM union_all ORDER BY atomic_number;
to get a unique identifier, the ROWID, in the result set. Note that this unique identifier is unique at any given time, but is not guaranteed to be stable. If you delete rows and add them again, the ROWID of the replaced rows may be different from before. But the ROWID will be unique until you edit the table.
+-------+--------+--------+--------------+-----------+--------+-------+
| rowid | atomic | symbol | name | atomic | period | group |
| | number | | | weight | | |
+-------+--------+--------+--------------+-----------+--------+-------+
| 257 | 1 | H | Hydrogen | 1.0079 | 1 | 1 |
| 258 | 2 | He | Helium | 4.0026 | 1 | 18 |
| 259 | 3 | Li | Lithium | 6.9410 | 2 | 1 |
| 260 | 4 | Be | Beryllium | 9.0122 | 2 | 2 |
| 266 | 4 | Be | Beryllium | 9.0122 | 2 | 2 |
| 267 | 5 | B | Boron | 10.8110 | 2 | 13 |
| 261 | 5 | B | Boron | 10.8110 | 2 | 13 |
| 268 | 6 | C | Carbon | 12.0110 | 2 | 14 |
| 262 | 6 | C | Carbon | 12.0110 | 2 | 14 |
| 263 | 7 | N | Nitrogen | 14.0070 | 2 | 15 |
| 264 | 8 | O | Oxygen | 15.9990 | 2 | 16 |
| 265 | 9 | F | Fluorine | 18.9980 | 2 | 17 |
| 269 | 9 | F | Fluorine | 18.9980 | 2 | 17 |
| 270 | 13 | Al | Aluminium | 26.9820 | 3 | 13 |
| 271 | 17 | Cl | Chlorine | 35.4530 | 3 | 17 |
| 272 | 18 | Ar | Argon | 39.9480 | 3 | 18 |
| 273 | 20 | Ca | Calcium | 40.0780 | 4 | 2 |
| 274 | 24 | Cr | Chromium | 51.9960 | 4 | 6 |
| 275 | 26 | Fe | Iron | 55.8450 | 4 | 8 |
| 276 | 27 | Co | Cobalt | 58.9330 | 4 | 9 |
| 277 | 29 | Cu | Copper | 63.5460 | 4 | 11 |
| 278 | 33 | As | Arsenic | 74.9220 | 4 | 15 |
| 279 | 35 | Br | Bromine | 79.9040 | 4 | 17 |
| 280 | 47 | Ag | Silver | 107.8700 | 5 | 11 |
| 281 | 48 | Cd | Cadmium | 112.4100 | 5 | 12 |
| 282 | 55 | Cs | Caesium | 132.9100 | 6 | 1 |
| 283 | 56 | Ba | Barium | 137.3300 | 6 | 2 |
| 284 | 58 | Ce | Cerium | 140.1200 | 6 | L |
| 285 | 63 | Eu | Europium | 151.9600 | 6 | L |
| 286 | 66 | Dy | Dyprosium | 162.5000 | 6 | L |
| 287 | 68 | Er | Erbium | 167.2600 | 6 | L |
| 288 | 79 | Au | Gold | 196.9700 | 6 | 11 |
| 289 | 83 | Bi | Bismuth | 208.9800 | 6 | 15 |
| 290 | 85 | At | Astatine | 209.9900 | 6 | 17 |
| 291 | 87 | Fr | Francium | 223.0200 | 7 | 1 |
| 292 | 89 | Ac | Actinium | 227.0300 | 7 | A |
| 293 | 95 | Am | Americium | 243.0600 | 7 | A |
| 294 | 96 | Cm | Curium | 247.0700 | 7 | A |
| 295 | 97 | Bk | Berkelium | 247.0700 | 7 | A |
| 296 | 98 | Cf | Californium | 251.0800 | 7 | A |
| 297 | 99 | Es | Einsteinium | 252.0800 | 7 | A |
| 298 | 100 | Fm | Fermium | 257.1000 | 7 | A |
| 299 | 105 | Db | Dubnium | 270.1300 | 7 | 5 |
| 300 | 107 | Bh | Bohrium | 270.1300 | 7 | 7 |
| 301 | 110 | Ds | Darmstadtium | 281.1700 | 7 | 10 |
| 302 | 112 | Cn | Copernicium | 285.1800 | 7 | 12 |
| 303 | 114 | Fl | Flerovium | 289.1900 | 7 | 14 |
+-------+--------+--------+--------------+-----------+--------+-------+
I'm reading line by line from a file then inserting the details in a mysql database. But the issue is that some lines do not contain a field I called natted ip and port. I loop through the file then insert into db. However the issue is that because not every row contains natted ip and port, I need the database to skip these two columns when inserting into the table where they do not appear but insert the rest and not duplicate. How can I ensure that?
public static void readData() throws ClassNotFoundException, SQLException{
File fileName = new File(FILE);
try(Scanner input = new Scanner(fileName) ){
String firstLine, secondLine, thirdLine;
firstLine = input.nextLine();
secondLine = input.nextLine();
String[] secondString = secondLine.split(" ");
for(String string: secondString){
timestamp = secondString[0]+" "+secondString[1]; //to be inserted
timezone = secondString[2]; //to be inserted
}
thirdLine = input.nextLine();
String[] thirdString = thirdLine.split(":");
for(String string: thirdString){
session = thirdString[1].trim(); //to be inserted
}
while(input.hasNextLine()){
String line;
line = input.nextLine();
String[] cdr_string = line.split(" ");
for(String string:cdr_string){
type = cdr_string[1].trim(); //to be inserted
internalIP_and_port = cdr_string[8];
destinationIP_and_port = cdr_string[10].trim();
}
if(internalIP_and_port.contains("[")){
String[] splitIPs = internalIP_and_port.split(Pattern.quote("["));
for(String string:splitIPs){
internalIP_and_port = splitIPs[0].trim();
nattedIP_and_port = splitIPs[1].trim();
nattedIP_and_port = nattedIP_and_port.substring(0, nattedIP_and_port.length() -1);
}
String[] splitIP_and_port = nattedIP_and_port.split(":");
for(String string:splitIP_and_port){
natted_ip = splitIP_and_port[0].trim(); //to be inserted
natted_port = splitIP_and_port[1].trim(); //to be inserted
}
// System.out.println(natted_ip);
}
String[] split_internal_IP_and_port = internalIP_and_port.split(":");
for(String string : split_internal_IP_and_port){
internal_ip = split_internal_IP_and_port[0].trim(); //to be inserted
internal_port = split_internal_IP_and_port[1].trim(); //to be inserted
}
String[] split_destination_IP_and_port = destinationIP_and_port.split(":");
for(String string : split_destination_IP_and_port){
destination_ip = split_destination_IP_and_port[0].trim(); //to be inserted
destination_port = split_destination_IP_and_port[1].trim(); //to be inserted
}
saveData();
}
}catch(IOException ex){
System.out.println(ex);
}
File log_done = new File(FILE_DONE);
fileName.renameTo(log_done);
fileName.delete();
}
private static void saveData() throws ClassNotFoundException, SQLException{
Connection con = connect();
PreparedStatement stmt = con.prepareStatement("INSERT INTO decoder(type, internal_ip, internal_port, natted_ip, natted_port, destination_ip, destination_port, session, timestamp, timezone, filename) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
stmt.setString(1, type);
stmt.setString(2, internal_ip);
stmt.setString(3, internal_port);
stmt.setString(4, natted_ip);
stmt.setString(5, natted_port);
stmt.setString(6, destination_ip);
stmt.setString(7, destination_port);
stmt.setString(8, session);
stmt.setString(9, timestamp);
stmt.setString(10, timezone);
stmt.setString(11, FILENAME);
stmt.executeUpdate();
}
public static Connection connect() throws ClassNotFoundException, SQLException{
Class.forName("com.mysql.jdbc.Driver");
return DriverManager.getConnection(URL, USERNAME, PASSWORD);
}```
I'm reading from this file:
udp VPN: public --> public 41.72.118.178:56620 --> 103.10.116.19:51130
https VPN: public --> public 10.65.19.224:46765[165.56.53.149:15674] --> 31.13.75.36:443
tcp VPN: public --> public 35.212.240.3:34533 --> 41.72.96.58:20792
dns VPN: public --> public 10.65.179.189:12718 --> 165.56.45.2:53
https VPN: public --> public 10.65.145.37:34490[165.56.53.161:38013] --> 185.60.219.9:443
https VPN: public --> public 10.65.14.63:43956[165.56.53.178:27552] --> 216.58.223.106:443
https VPN: public --> public 10.66.32.44:37573[165.56.53.141:29821] --> 185.60.219.33:443
udp VPN: public --> public 172.21.242.243:10188[41.72.123.88:55777] --> 119.3.74.66:10327
http VPN: public --> public 172.21.218.82:65167[41.72.121.132:46765] --> 5.45.58.214:80
https VPN: public --> public 10.66.118.81:52792[165.56.53.185:46319] --> 104.82.200.59:443
udp VPN: public --> public 76.64.76.78:13114 --> 41.72.108.238:34835
I want it to show like this:
+----+----------+----------------+---------------+---------------+------------
| id | type | internal_ip | internal_port | natted_ip | natted_port
+----+----------+----------------+---------------+---------------+------------
| 1 | udp | 41.72.118.178 | 56620 | NULL | NULL |
| 2 | https | 10.65.19.224 | 46765 | 165.56.53.149 | 15674 |
| 3 | tcp | 35.212.240.3 | 34533 | NULL | NULL |
| 4 | dns | 10.65.179.189 | 12718 | NULL | NULL |
| 5 | https | 10.65.145.37 | 34490 | 165.56.53.161 | 38013 |
| 6 | https | 10.65.14.63 | 43956 | 165.56.53.178 | 27552 |
| 7 | https | 10.66.32.44 | 37573 | 165.56.53.141 | 29821 |
| 8 | udp | 172.21.242.243 | 10188 | 41.72.123.88 | 55777 |
| 9 | http | 172.21.218.82 | 65167 | 41.72.121.132 | 46765 |
| 10 | https | 10.66.118.81 | 52792 | 165.56.53.185 | NULL |
| 11 | udp | 76.64.76.78 | 13114 | NULL | NULL |
| 12 | https | 10.66.81.19 | 34736 | 165.56.53.81 | 29021 |
| 13 | tcp | 10.66.18.62 | 55976 | 165.56.53.233 | 62585
And not like this:
+----+----------+----------------+---------------+---------------+------------
| id | type | internal_ip | internal_port | natted_ip | natted_port
+----+----------+----------------+---------------+---------------+------------
| 1 | udp | 41.72.118.178 | 56620 | NULL | NULL |
| 2 | https | 10.65.19.224 | 46765 | 165.56.53.149 | 15674 |
| 3 | tcp | 35.212.240.3 | 34533 | 165.56.53.149 | 15674 |
| 4 | dns | 10.65.179.189 | 12718 | 165.56.53.149 | 15674 |
| 5 | https | 10.65.145.37 | 34490 | 165.56.53.161 | 38013 |
| 6 | https | 10.65.14.63 | 43956 | 165.56.53.178 | 27552 |
| 7 | https | 10.66.32.44 | 37573 | 165.56.53.141 | 29821 |
| 8 | udp | 172.21.242.243 | 10188 | 41.72.123.88 | 55777
you should initialize natted_ip and natted_port outside of for like below code.
because this variables save data from previous record and you don't clear them. it can be happen for all variables that can be null.
natted_ip = null;
natted_port = null;
for(String string:splitIP_and_port){
natted_ip = splitIP_and_port[0].trim();
natted_port = splitIP_and_port[1].trim();
}
I have a table name test;
mysql> desc test;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | 0 | |
| name | varchar(255) | YES | | NULL | |
| gendar | varchar(255) | YES | | NULL | |
+--------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> select * from test;
+----+------+--------+
| id | name | gendar |
+----+------+--------+
| 0 | John | male |
+----+------+--------+
1 row in set (0.00 sec)
And have a hibernate Entity like this:
#Entity
#Table(name = "test",schema = "", catalog = "mydb")
public class TestEntity {
private int id;
private String name;
private String gendar;
#Id
#Column(name = "id")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
#Basic
#Column(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Basic
#Column(name = "gendar")
public String getGendar() {
return gendar;
}
public void setGendar(String gendar) {
this.gendar = gendar;
}
}
The hibernate.xml is:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/mydb</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">test</property>
<property name="connection.password">test</property>
<mapping class="me.armnotstrong.sql.TestEntity" />
<!-- DB schema will be updated if needed -->
<!-- <property name="hbm2ddl.auto">update</property> -->
</session-factory>
</hibernate-configuration>
The hibernate session is generated by this factory class:
public class HBSession {
private static final SessionFactory ourSessionFactory;
private static final ServiceRegistry serviceRegistry;
static {
try {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
ourSessionFactory = configuration.buildSessionFactory(serviceRegistry);
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
Session session = ourSessionFactory.openSession();
return session;
}
}
And I just add a user to the db by this
public class TestHb {
public static void main(String[] argvs){
Session session = HBSession.getSession();
TestEntity testEntity = new TestEntity();
testEntity.setName("John");
testEntity.setGendar("male");
Transaction tx = session.beginTransaction();
session.save(testEntity);
tx.commit();
session.close();
}
}
After run the TestHB code above to add a user to mysql, the session seemed to just hang there, and won't colse, diagnose using netstat -nap just proved my guess, but it's ok, I think. In fact, this just simulate the condition of a long connection to the db in the product environment which hibernate make.
The question comes that, when I alter the table when hibernate connection still there, The mysql client just blocked. and wont do the alter action as presumed unless I restart the mysql service. and in product environment, after restart the mysql service, one thing come after another, The hibernate app will not work anymore.
So what should I do to alter the table and keep my hibernate also working?
as required by #Florent, here is some addition info come out of command SHOW FULL PROCESSLIST and SHOW OPEN TABLES;
mysql> show open tables;
+----------+----------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+----------+--------+-------------+
| test | merchant | 0 | 0 |
| test | test | 0 | 0 |
| test | orders | 0 | 0 |
| test | product | 0 | 0 |
| test | codes | 0 | 0 |
+----------+----------+--------+-------------+
5 rows in set (0.02 sec)
mysql> show full processlist;
+-----+--------+-----------------+--------+---------+------+-------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+--------+-----------------+--------+---------+------+-------+-----------------------+
| 42 | test | localhost:35790 | test | Sleep | 4 | | NULL |
| 43 | test | localhost:35801 | test | Sleep | 4 | | NULL |
| 44 | test | localhost:35802 | test | Sleep | 4 | | NULL |
| 45 | test | localhost:35803 | test | Sleep | 4 | | NULL |
| 46 | test | localhost:35804 | test | Sleep | 4 | | NULL |
| 157 | test | localhost:51516 | test | Sleep | 174 | | NULL |
| 161 | test | localhost:53988 | test | Sleep | 174 | | NULL |
| 180 | test | localhost:58501 | test | Sleep | 174 | | NULL |
| 192 | test | localhost:47228 | test | Sleep | 7217 | | NULL |
| 193 | test | localhost:49372 | test | Sleep | 4485 | | NULL |
| 196 | test | localhost | test | Sleep | 9256 | | NULL |
| 197 | test | localhost | test | Sleep | 4555 | | NULL |
| 198 | test | localhost:42411 | test | Sleep | 4485 | | NULL |
| 200 | test | localhost | test | Query | 0 | NULL | show full processlist |
+-----+--------+-----------------+--------+---------+------+-------+-----------------------+
14 rows in set (0.00 sec)
In the example below how to add the formula in individual user totals as the number of rows for the user can vary.
+------+--------------+---------+--------------+-------+
| Name | Date | Billable| Non-Billable | Total |
+------+--------------+---------+--------------+-------+
| abc | 06/23/2012 | 860 | 10 | 870 |
| | User Totals: | 860 | 10 | 870 |
| xyz | 07/12/2012 | 45 | 0 | 45 |
| | User Totals: | 45 | 0 | 45 |
| ccc | 09/19/2013 | 165 | 35 | 200 |
| | 10/15/2013 | 240 | 0 | 240 |
| | User Totals: | 405 | 35 | 440 |
| | Grand Totals | 1310| 45 | 1355 |
+------+--------------+---------+--------------+-------+