Tag Archives: MySQL

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver on eclipse

You need to add jar file to build path

right click on project->build path->configure build path->libraries tab ->add external jar

browse it and add it.

after adding also if u not getting same error, then

You must include the jar file in the Deployment Assembly of the Project.

1)select the web project which contains the jsp file

2)select Project tab in the menubar in Eclipse

3)select properties in the drop down menu

4)select Deployment Assembly

5)Add your ojdbc6.jar file in it..

Share

Install MySQL Linux CentOS

Download Package

yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm -y

Install MySQL

yum install mysql-community-server -y

Start MySQL

service mysqld start
service mysqld status

Generate Temporary password

grep 'temporary password' /var/log/mysqld.log

Login To MySQL

mysql -uroot -p

Reset Password and set Privilages

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@123';

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Root@123' WITH GRANT OPTION;

FLUSH PRIVILEGES;

Open MySQL Port 3306

firewall-cmd --zone=public --add-port=3306/tcp --permanent

firewall-cmd --reload

firewall-cmd --list-all
Share

Prepared Statements MySQL

Similar in concept to templates – contain compiled code used to run common sql operations

o Advantages:

 Query only parsed once, but allows for multiple executions, with same or different parameters (performance consideration)

 Related parameters do not need to be quoted (security consideration)

o Only feature pdo will emulate for adapters that do not support prepared statements

Share

Transactions

• Combines individual sql operations into one
• Usually start with begin or begin transaction
• Execute the transaction using commit
• Cancel the transaction using rollback

Example

START TRANSACTION; SELECT @A:=SUM(salary) FROM table1 WHERE type=1; UPDATE table2 SET summary=@A WHERE type=1; COMMIT;
Share

Unbuffered Queries

Unbuffered MySQL queries execute the query and then return a resource while the data is still waiting on the MySQL server for being fetched. This uses less memory on the PHP-side, but can increase the load on the server. Unless the full result set was fetched from the server no further queries can be sent over the same connection. Unbuffered queries can also be referred to as “use result”.

Share