Database Archives - Page 5 of 5

Java | Execute SQL script using Maven

Author - Rita

Whenever there is a change in the database whether we are altering database structure or adding/updating data inside database most of the times we create a script file and run it manually. We can automate this process using Maven.

Solution: Maven provides a plugin called flyway-maven-plugin to Read more…

MySQL | How to automatically update timestamp field

Author - Webner
|
0 Comments
|

Sometimes, we need to check when was the data last accessed. In MySQL, we had taken a field last_modified_time as timestamp datatype in a table, which was set to CURRENT_TIMESTAMP by DEFAULT.

When a new record was inserted, it automatically updated the field and set the current datetime into this Read more…

Eclipse | Ctrl+click doesn’t redirect to parent function or class

Author - Webner
|
0 Comments
|

While working in eclipse, we faced a problem in which Ctrl+click was not redirecting to the parent function or class.

Solution: To solve this problem, we followed the below steps :

1. Exit Eclipse
2. Go to Workspace
3. Open .metadata folder
4. Open .plugins folder
5. Search for folder Read more…

Mysql | How to access database remotely

Author - Kiran Preet

To access Mysql database remotely a good way is to create a new Mysql user and grant it permissions to access database from remote, as explained below:

You can create user with two ways

From Mysql command prompt:

1. Open command prompt.

2. Open the terminal of MYSQL Read more…

SQL Server / MySQL | Combine data from multiple rows into a single row

Author - Webner
|
0 Comments
|

We have data as below:

We need output like this:

Solution:
For SQL server
STUFF function is the key here:
SELECT Id,STUFF(
(
SELECT distinct ‘ ‘ + cast(Name as varchar(500)) from table1 t2 where t1.Id = t2.Id FOR XML PATH(”), TYPE ).value(‘.’, ‘NVARCHAR(MAX)’) ,1 Read more…

Mysql | Maximum execution time of 360 seconds exceeded at data import time

Author - Webner

In one of the project we had to import some .csv files into Mysql database. Files were of size 80mb and more. When we tried to upload the files through phpmyadmin it was resulting in timeout error – Maximum execution time of 360 seconds exceeded (see image below):

A better solution Read more…

Joomla- Database Error: Unable to connect to the database

Author - Webner

While working with Joomla if you get an error – “Database Error: Unable to connect to the database:Could not connect to database”, check following properties in Joomla’s configuration.php file :

//given values are sample data only.

var $dbtype = ‘mysql’;

var $host = ‘localhost’;

var $user = ‘user_jo151’;

var $password = ‘YourPassword’;

var Read more…

Moodle | Fetch all the categories based on the programs assigned to a user

Author - Neha Mishra

Below are the Moodle database tables that will be used to fetch all the categories based on the programs assigned to a user (complete query is also written after table information):
1. mdl_prog : This table contains each program along with the category to which program belongs, its summary, fullname and Read more…

Mysql | Forgot root password in Mysql

Author - Navneet Kashyap

If you forget mysql root password these are few easy steps to regain access:
1. shell> mysqld_safe –skip-grant-tables
2.Open another terminal shell> mysql -u root -p (hit enter and use blank password)
3. mysql>UPDATE mysql.user SET Password=PASSWORD(‘NewPassword’)WHERE User=’root’;

4. mysql>FLUSH Read more…

Couple of approaches to generate test-data in bulk

Author - Rita

Sometimes you need to fill a database table with thousands of test data records. You may also need to generate test data in the form of csv file to feed to a program. How can you generate such a large set of data in short time?
One approach to generate Read more…

Moodle | Call to undefined method mysqli_native_moodle_database :: insert_records()

Author - Manju Kashyap

We were using insert_records() function to insert multiple records in a Moodle database table but it was not working.

We checked for errors by adding following lines in config.php file of moodle:
@error_reporting(E_ALL | E_STRICT);

@ini_set(‘display_errors’, ‘1’);

$CFG->debug = (E_ALL | E_STRICT);

$CFG->debugdisplay = 1 Read more…

SQL Server not starting at startup and even not starts manually

Author - Webner

In one case we noticed that SQL Server (SQL Server 2014) service was scheduled to start Automatically on system boot but still it was not starting up. It did not even start when we manually tried to start the service. We got following errors:

Error1: A timeout was reached (30000 Read more…

Mysql | How to drop table having dot (.) in the table name in MySQL

Author - Rita
|
0 Comments
|

We had a table in our database having dot in the table name as below:

Table name – kpc.product_categories

On trying to delete kpc.product_categories using below command:

drop table kpc.product_categories

It used to give error that no such table exists.

Dot(.) is the reserved symbol in mysql so Read more…

Heroku | How to delete prior database backups

Author - Namisha

Following are the steps to delete the Postgres database backup:

1. Login into heroku.

2. Click on the database>PG Backups. Here you can see all the PG backups list.

3. . For deleting the database, first of all you have to install the toolbelt.

You can download Toolbelt from Read more…

Zoho CRM | Reduce API call consumption

Author - Webner

This is a simple idea to reduce API calls consumption when you pull data from Zoho CRM into an integrated piece of code (like server side code in PHP or Java that connects to Zoho CRM to retrieve records). In one of the projects we were working on, we had Read more…

Heroku – Find out database backup retained limit

Author - Webner
|
0 Comments
|

To see the database backup retained limit see the steps followed below:

1. Login into heroku.

2.Now click the database you are using. As you can see in the below screenshot database name is Heroku Postgres – Charcoal and it is Hobby Basic and it is purchased with Read more…

Error Code: 3. Error writing file ‘/tmp/MYMI5iqH’ (Errcode: 28)

Author - Webner

Problem

Recently in a website we were developing in Codeigniter PHP Framework, some of the urls stopped working and started throwing 500 internal server error. On investigation we found a MySQL query which was causing the problem .Query is simple but when we ran it Read more…

Importance of Website for Business – Part 3

Author - Webner

In previous 2 posts in this series we covered benefits of having a website for your business and difference between Responsive and Non-Responsive website. We also shared some stats on how small business presence on Internet is going up.

In this third and final post of “Importance of Website Read more…

Connection Pool with Tomcat6 and Mysql

Author - Webner
|
0 Comments
|

Inside $tomcat_home/conf/context.xml add this inside <Context>
<Resource name=”jdbc/datasourcename” auth=”Container” type=”javax.sql.DataSource” maxActive=”100″ maxIdle=”30″ maxWait=”1000″ username=”dbuser” password=”dbpwd” driverClassName=”com.mysql.jdbc.Driver” url=”jdbc:mysql://localhost:3306/exodus”/>
Now restart tomcat

Inside Read more…

ORA-28001: the password has expired

Author - Webner
|
0 Comments
|

That’s the error you get for oracle user for whom password is expired.

One Solution – Connect using sqlplus to set new password, you can even use the same password you had earlier.

$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 13 01:12:07 Read more…