473,388 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

how to connect in database

hi......can you please help me to connect in database using perl...what is the appropriate database to use and what is the connection string.....
thank you...
Sep 19 '08 #1
2 1351
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use DBI;
  3.  
  4. my $db = DBI->connect( 'databasename',
  5.                         'username',
  6.                         'usepassword',
  7. $db->disconnect();
  8.  
Sep 19 '08 #2
numberwhun
3,509 Expert Mod 2GB
erpritish: The way that you have written that code it would fail. The format is incorrect and it includes an out of place disconnect all within the same statement. Also, when you post code in the forums, you really need to use the necessary code tags. There is an example of them to the right of the Reply window in the "Reply Guidelines" box. Please use them next time. Also, in these forums, we don't just provide code that is requested as this is not a scripting service. While I know you are being helpful, it does not help the OP learn.

fatimang: You are really going to want to take a look at the DBI module page on CPAN . It will tell you all that you need to know about connecting to a database. In the mean time try this:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use DBI:
  4. use DBD::mysql;
  5.  
  6. my $Host = "localhost";
  7. my $DbName = "dbname";
  8. my $DbUser = "username";
  9. my $DbPassword = "xxxxx"; # personally, I would pull this from a config file.
  10.  
  11. $dbh = DBI->connect("dbi:mysql:host=$Host;database=$DbName", $DbUser , $DbPassword) or die;
  12.  
That will at least get you connected to the database, but what you do from there is up to you. I know that I said earlier in this post that I don't normally just give out code, as it won't help you learn, but since the other OP provided you what they did, I posted this to give you a better example. Next time you will probably be asked to show the code you have tried and any errors you see as well.

Regards,

Jeff
Sep 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Mr Dygi | last post by:
Hi, PHP 4.3.4 installed manually from package *.zip and Apache 2. I have a problem with this simple code: <?php $link = mysql_connect("127.0.0.1","","") or die("Could not connect: " ....
1
by: DAVID | last post by:
Hello, With regards to the Connect dialog on Oracle forms 6i via which we can connect to Oracle database, should we use the same functionality on forms run time again? I mean, I want to make a...
3
by: Lee | last post by:
Hi, I'm developing a socket program to connect to Informix database through the ODBC. In here i called my socket program as "tap" . My tap will listen for data from unix through port 1070. After...
4
by: Scott Holland | last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also AS/400 from NT Server -- I am experienced in ORACLE and a novice at DB2. What tools would be the equivalent of Net*8 or...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
3
by: Jassim Rahma | last post by:
I would like to know what is the best way to onnect to connect to a database in general which provides you with full functionality & fast access? Best Regards, Jassim Rahma *** Sent via...
1
by: GNoter | last post by:
Scenario: I've a WebFarm with 2 web servers which are NLBs (network load balanced). Web1 and Web2; they are not part of a domain. I have a third server, Server3, which is part of a domain and on...
21
by: Steve | last post by:
I moved my database from one server to another SQL server. I did a backup and restore of the database. I can connect to the database on server A from my asp.net app but when I try to connect to my...
2
by: jeffhan | last post by:
we have os/400 db2 database at the backend. i installed db2 v9 connect server on one windows server which is locating the same network with database server. now how to i configure the connect...
5
by: danfan46 | last post by:
Hi! I have a previous post on the subject that connect takes a long time. I uninstalled db2 completely. Installed V9.5 Installed fixpack 1 created das created an instance installed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.